Action Manager convert path to shape
Hi, I've been trying to automate a task, but got stuck hard on an issue (couple of hours of various retries without success).
What I'm trying to do: convert selected layer to a shape.
Workflow: select layer, ctrl select it (to highlight), "Make work path from selection", convert to shape (pen tool, shape button).
I can get everything to work except the last step (convert path to shape). I've tried to include and exclude select pen tool, didn't do anything.
When I run my script, it creates the path, creates a shape layer, but it has no color. Looking through the raw code, I've noticed one "magic number", and after testing a little, I've figured out it's a max layer id + 1 (so I guess new layer id?).
I've also tried to remove this number (and the `putInteger`), didn't help either.
When I run the script without the last step, and manually click on the shape button, it works, and produces the exact same raw code.
At this point, I can't pin-point anything that could be causing the issue.
The raw code to convert path to shape is below. In this case, the magic number is 102 (right at the bottom). I didn't notify it whatsoever yet.
var idMk = charIDToTypeID( "Mk " );
var desc257 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref17 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref17.putClass( idcontentLayer );
desc257.putReference( idnull, ref17 );
var idUsng = charIDToTypeID( "Usng" );
var desc258 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc259 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc260 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc260.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc260.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc260.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc259.putObject( idClr, idRGBC, desc260 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc258.putObject( idType, idsolidColorLayer, desc259 );
var idShp = charIDToTypeID( "Shp " );
var desc261 = new ActionDescriptor();
var idTrgp = charIDToTypeID( "Trgp" );
var idPthK = charIDToTypeID( "PthK" );
var idTrgp = charIDToTypeID( "Trgp" );
desc261.putEnumerated( idTrgp, idPthK, idTrgp );
var idpathClass = stringIDToTypeID( "pathClass" );
desc258.putObject( idShp, idpathClass, desc261 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc262 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc262.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc262.putBoolean( idstrokeEnabled, false );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc262.putBoolean( idfillEnabled, true );
var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
var idPxl = charIDToTypeID( "#Pxl" );
desc262.putUnitDouble( idstrokeStyleLineWidth, idPxl, 1.000000 );
var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
var idPnt = charIDToTypeID( "#Pnt" );
desc262.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );
var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
desc262.putDouble( idstrokeStyleMiterLimit, 100.000000 );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );
desc262.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
desc262.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );
desc262.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );
var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
desc262.putBoolean( idstrokeStyleScaleLock, false );
var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
desc262.putBoolean( idstrokeStyleStrokeAdjust, false );
var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
var list15 = new ActionList();
desc262.putList( idstrokeStyleLineDashSet, list15 );
var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
var idBlnM = charIDToTypeID( "BlnM" );
var idNrml = charIDToTypeID( "Nrml" );
desc262.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );
var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
var idPrc = charIDToTypeID( "#Prc" );
desc262.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc263 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc264 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc264.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc264.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc264.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc263.putObject( idClr, idRGBC, desc264 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc262.putObject( idstrokeStyleContent, idsolidColorLayer, desc263 );
var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
desc262.putDouble( idstrokeStyleResolution, 72.000000 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc258.putObject( idstrokeStyle, idstrokeStyle, desc262 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc257.putObject( idUsng, idcontentLayer, desc258 );
var idLyrI = charIDToTypeID( "LyrI" );
desc257.putInteger( idLyrI, 102 );
executeAction( idMk, desc257, DialogModes.NO );
