Copy link to clipboard
Copied
Tried to use script listener to capture AM code for setting the corner radius of rectangle shapes. Below is what I got and it seems logical, but nothing happens when I run it independently. The right layer is selected but maybe I need to set a reference to the layer somehow? AM side is not my strong suit so hoping someone can pick up my mistake.. Example has 8px radius that was set with all corners locked, but I've also tried replacing 0's with the value.
var idchangePathDetails = stringIDToTypeID( "changePathDetails" );
var desc22 = new ActionDescriptor();
var idkeyOriginType = stringIDToTypeID( "keyOriginType" );
desc22.putInteger( idkeyOriginType, 1 );
var idkeyOriginRRectRadii = stringIDToTypeID( "keyOriginRRectRadii" );
var desc23 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc23.putInteger( idunitValueQuadVersion, 1 );
var idtopRight = stringIDToTypeID( "topRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idtopRight, idPxl, 0 );
var idtopLeft = stringIDToTypeID( "topLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idtopLeft, idPxl, 8.0 );
var idbottomLeft = stringIDToTypeID( "bottomLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idbottomLeft, idPxl, 0 );
var idbottomRight = stringIDToTypeID( "bottomRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idbottomRight, idPxl, 0 );
var idradii = stringIDToTypeID( "radii" );
desc22.putObject( idkeyOriginRRectRadii, idradii, desc23 );
var idkeyActionRadiiSource = stringIDToTypeID( "keyActionRadiiSource" );
desc22.putInteger( idkeyActionRadiiSource, 1 );
var idkeyActionChangeAllCorners = stringIDToTypeID( "keyActionChangeAllCorners" );
desc22.putBoolean( idkeyActionChangeAllCorners, true );
executeAction( idchangePathDetails, desc22, DialogModes.NO );
which version of PS do you use?
This is a possible AM-Code for creating a vector shape
...var idMk = charIDToTypeID( "Mk " );
var desc10 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref2.putClass( idcontentLayer );
desc10.putReference( idnull, ref2 );
var idUsng = charIDToTypeID( "Usng" );
var desc11 = new ActionDescriptor(
Copy link to clipboard
Copied
which version of PS do you use?
This is a possible AM-Code for creating a vector shape
var idMk = charIDToTypeID( "Mk " );
var desc10 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref2.putClass( idcontentLayer );
desc10.putReference( idnull, ref2 );
var idUsng = charIDToTypeID( "Usng" );
var desc11 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc12 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc13 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc13.putDouble( idRd, 255.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc13.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc13.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc12.putObject( idClr, idRGBC, desc13 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc11.putObject( idType, idsolidColorLayer, desc12 );
var idShp = charIDToTypeID( "Shp " );
var desc14 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc14.putInteger( idunitValueQuadVersion, 1 );
var idTop = charIDToTypeID( "Top " );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idTop, idPxl, 101.000000 );
var idLeft = charIDToTypeID( "Left" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idLeft, idPxl, 54.000000 );
var idBtom = charIDToTypeID( "Btom" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idBtom, idPxl, 353.000000 );
var idRght = charIDToTypeID( "Rght" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idRght, idPxl, 439.000000 );
var idtopRight = stringIDToTypeID( "topRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idtopRight, idPxl, 8.000000 );
var idtopLeft = stringIDToTypeID( "topLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idtopLeft, idPxl, 8.000000 );
var idbottomLeft = stringIDToTypeID( "bottomLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idbottomLeft, idPxl, 8.000000 );
var idbottomRight = stringIDToTypeID( "bottomRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc14.putUnitDouble( idbottomRight, idPxl, 8.000000 );
var idRctn = charIDToTypeID( "Rctn" );
desc11.putObject( idShp, idRctn, desc14 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc15 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc15.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc15.putBoolean( idstrokeEnabled, false );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc15.putBoolean( idfillEnabled, true );
var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
var idPnt = charIDToTypeID( "#Pnt" );
desc15.putUnitDouble( idstrokeStyleLineWidth, idPnt, 0.000000 );
var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
var idPnt = charIDToTypeID( "#Pnt" );
desc15.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );
var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
desc15.putDouble( idstrokeStyleMiterLimit, 100.000000 );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );
desc15.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
desc15.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );
desc15.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );
var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
desc15.putBoolean( idstrokeStyleScaleLock, false );
var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
desc15.putBoolean( idstrokeStyleStrokeAdjust, false );
var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
var list1 = new ActionList();
desc15.putList( idstrokeStyleLineDashSet, list1 );
var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
var idBlnM = charIDToTypeID( "BlnM" );
var idNrml = charIDToTypeID( "Nrml" );
desc15.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );
var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
var idPrc = charIDToTypeID( "#Prc" );
desc15.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc16 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc17 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc17.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc17.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc17.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc16.putObject( idClr, idRGBC, desc17 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc15.putObject( idstrokeStyleContent, idsolidColorLayer, desc16 );
var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
desc15.putDouble( idstrokeStyleResolution, 72.000000 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc11.putObject( idstrokeStyle, idstrokeStyle, desc15 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc10.putObject( idUsng, idcontentLayer, desc11 );
var idLyrI = charIDToTypeID( "LyrI" );
desc10.putInteger( idLyrI, 2 );
executeAction( idMk, desc10, DialogModes.NO );
and this is only for creating a path
var idsetd = charIDToTypeID( "setd" );
var desc18 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idPath = charIDToTypeID( "Path" );
var idWrPt = charIDToTypeID( "WrPt" );
ref3.putProperty( idPath, idWrPt );
desc18.putReference( idnull, ref3 );
var idT = charIDToTypeID( "T " );
var desc19 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc19.putInteger( idunitValueQuadVersion, 1 );
var idTop = charIDToTypeID( "Top " );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idTop, idPxl, 70.000000 );
var idLeft = charIDToTypeID( "Left" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idLeft, idPxl, 49.000000 );
var idBtom = charIDToTypeID( "Btom" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idBtom, idPxl, 244.000000 );
var idRght = charIDToTypeID( "Rght" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idRght, idPxl, 445.000000 );
var idtopRight = stringIDToTypeID( "topRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idtopRight, idPxl, 8.000000 );
var idtopLeft = stringIDToTypeID( "topLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idtopLeft, idPxl, 8.000000 );
var idbottomLeft = stringIDToTypeID( "bottomLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idbottomLeft, idPxl, 8.000000 );
var idbottomRight = stringIDToTypeID( "bottomRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc19.putUnitDouble( idbottomRight, idPxl, 8.000000 );
var idRctn = charIDToTypeID( "Rctn" );
desc18.putObject( idT, idRctn, desc19 );
executeAction( idsetd, desc18, DialogModes.NO );
and this should change the corner radius of the shape
var idchangePathDetails = stringIDToTypeID( "changePathDetails" );
var desc26 = new ActionDescriptor();
var idkeyOriginType = stringIDToTypeID( "keyOriginType" );
desc26.putInteger( idkeyOriginType, 1 );
var idkeyOriginRRectRadii = stringIDToTypeID( "keyOriginRRectRadii" );
var desc27 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc27.putInteger( idunitValueQuadVersion, 1 );
var idtopRight = stringIDToTypeID( "topRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idtopRight, idPxl, 8.000000 );
var idtopLeft = stringIDToTypeID( "topLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idtopLeft, idPxl, 8.000000 );
var idbottomLeft = stringIDToTypeID( "bottomLeft" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idbottomLeft, idPxl, 8.000000 );
var idbottomRight = stringIDToTypeID( "bottomRight" );
var idPxl = charIDToTypeID( "#Pxl" );
desc27.putUnitDouble( idbottomRight, idPxl, 8.000000 );
var idradii = stringIDToTypeID( "radii" );
desc26.putObject( idkeyOriginRRectRadii, idradii, desc27 );
var idkeyActionRadiiSource = stringIDToTypeID( "keyActionRadiiSource" );
desc26.putInteger( idkeyActionRadiiSource, 1 );
var idkeyActionChangeAllCorners = stringIDToTypeID( "keyActionChangeAllCorners" );
desc26.putBoolean( idkeyActionChangeAllCorners, true );
executeAction( idchangePathDetails, desc26, DialogModes.NO );
Copy link to clipboard
Copied
It's latest CC 2015. The code for changing radius still does nothing, but your code to create rectangle with corner radius defined works! Thanks!
Copy link to clipboard
Copied
You're welcome.
---------------------------------------
Matias Kiviniemi schrieb:
It's latest CC 2015. The code for changing radius still does nothing …
Hmmhh?
I've tried it today at work with the latest PS CC 2015.
Do you really have had a live vector shape with a corner radius different from 8 px?
e.g. I've tried with 38px × 38px × 38px × 38px and run script snippet --> result: all corners of vector shape changed to 8px
e.g. I've tried with 47px × 38px × 38px × 38px and run script snippet --> result: all corners of vector shape changed, but in relation to 8 px --> 17px × 8px × 8px × 8px
The snippet gives funny results if one value is smaller than 8px before running the snippet.
Copy link to clipboard
Copied
I'm using the Win64 version and the rectangle had all corners with 0px, not sure why we're seeing different results (and why the creation works OK).
Copy link to clipboard
Copied
pixxxel schubser This corner edit script works flawlessly, can I've the edit storke width and color? I'm having a very hard time to get this.
Copy link to clipboard
Copied
in the script snippets? Or after the snippet is running?
Try this after creating a vector shape:
// +++++++++++++++++++
// settings //
var strokeRed = 0;
var strokeGrn = 255;
var strokeBlue= 0;
var strokeWdt = 10;
// +++++++++++++++++++
var idsetd = charIDToTypeID( "setd" );
var desc113 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref84 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref84.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc113.putReference( idnull, ref84 );
var idT = charIDToTypeID( "T " );
var desc114 = new ActionDescriptor();
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc115 = new ActionDescriptor();
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc116 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc117 = new ActionDescriptor();
desc117.putDouble( charIDToTypeID( "Rd " ), strokeRed );
desc117.putDouble( charIDToTypeID( "Grn " ), strokeGrn );
desc117.putDouble( charIDToTypeID( "Bl " ), strokeBlue );
var idRGBC = charIDToTypeID( "RGBC" );
desc116.putObject( idClr, idRGBC, desc117 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc115.putObject( idstrokeStyleContent, idsolidColorLayer, desc116 );
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc115.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc115.putBoolean( idstrokeEnabled, true );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc114.putObject( idstrokeStyle, idstrokeStyle, desc115 );
var idshapeStyle = stringIDToTypeID( "shapeStyle" );
desc113.putObject( idT, idshapeStyle, desc114 );
executeAction( idsetd, desc113, DialogModes.NO );
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc151 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref96 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref96.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc151.putReference( idnull, ref96 );
var idT = charIDToTypeID( "T " );
var desc152 = new ActionDescriptor();
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc153 = new ActionDescriptor();
desc153.putUnitDouble( stringIDToTypeID( "strokeStyleLineWidth" ), charIDToTypeID( "#Pnt" ), strokeWdt );
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc153.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc153.putBoolean( idstrokeEnabled, true );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc152.putObject( idstrokeStyle, idstrokeStyle, desc153 );
var idshapeStyle = stringIDToTypeID( "shapeStyle" );
desc151.putObject( idT, idshapeStyle, desc152 );
executeAction( idsetd, desc151, DialogModes.NO );
Have fun
Copy link to clipboard
Copied
pixxxel schubser, Thanks very appreciated.