Simpler way to draw a circle with scripting

Explorer ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Hello

Is there a simpler way to create circle shape with scripting instead using the long generated code(extracted from xbytor tool) below:

function Circle() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(stringIDToTypeID("contentLayer"));
    desc1.putReference(charIDToTypeID('null'), ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(charIDToTypeID('Rd  '), 255);
    desc4.putDouble(charIDToTypeID('Grn '), 255);
    desc4.putDouble(charIDToTypeID('Bl  '), 255);
    desc3.putObject(charIDToTypeID('Clr '), stringIDToTypeID("RGBColor"), desc4);
    desc2.putObject(charIDToTypeID('Type'), stringIDToTypeID("solidColorLayer"), desc3);
    var desc5 = new ActionDescriptor();
    desc5.putInteger(stringIDToTypeID("unitValueQuadVersion"), 1);
    desc5.putUnitDouble(charIDToTypeID('Top '), charIDToTypeID('#Pxl'), 124);
    desc5.putUnitDouble(charIDToTypeID('Left'), charIDToTypeID('#Pxl'), 164);
    desc5.putUnitDouble(charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), 268);
    desc5.putUnitDouble(charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), 308);
    desc2.putObject(charIDToTypeID('Shp '), charIDToTypeID('Elps'), desc5);
    var desc6 = new ActionDescriptor();
    desc6.putInteger(stringIDToTypeID("strokeStyleVersion"), 2);
    desc6.putBoolean(stringIDToTypeID("strokeEnabled"), false);
    desc6.putBoolean(stringIDToTypeID("fillEnabled"), true);
    desc6.putUnitDouble(stringIDToTypeID("strokeStyleLineWidth"), charIDToTypeID('#Pxl'), 1);
    desc6.putUnitDouble(stringIDToTypeID("strokeStyleLineDashOffset"), charIDToTypeID('#Pnt'), 0);
    desc6.putDouble(stringIDToTypeID("strokeStyleMiterLimit"), 100);
    desc6.putEnumerated(stringIDToTypeID("strokeStyleLineCapType"), stringIDToTypeID("strokeStyleLineCapType"), stringIDToTypeID("strokeStyleButtCap"));
    desc6.putEnumerated(stringIDToTypeID("strokeStyleLineJoinType"), stringIDToTypeID("strokeStyleLineJoinType"), stringIDToTypeID("strokeStyleRoundJoin"));
    desc6.putEnumerated(stringIDToTypeID("strokeStyleLineAlignment"), stringIDToTypeID("strokeStyleLineAlignment"), stringIDToTypeID("strokeStyleAlignCenter"));
    desc6.putBoolean(stringIDToTypeID("strokeStyleScaleLock"), false);
    desc6.putBoolean(stringIDToTypeID("strokeStyleStrokeAdjust"), false);
    var list1 = new ActionList();
    desc6.putList(stringIDToTypeID("strokeStyleLineDashSet"), list1);
    desc6.putEnumerated(stringIDToTypeID("strokeStyleBlendMode"), charIDToTypeID('BlnM'), charIDToTypeID('Nrml'));
    desc6.putUnitDouble(stringIDToTypeID("strokeStyleOpacity"), charIDToTypeID('#Prc'), 100);
    var desc7 = new ActionDescriptor();
    var desc8 = new ActionDescriptor();
    desc8.putDouble(charIDToTypeID('Rd  '), 0);
    desc8.putDouble(charIDToTypeID('Grn '), 0);
    desc8.putDouble(charIDToTypeID('Bl  '), 0);
    desc7.putObject(charIDToTypeID('Clr '), stringIDToTypeID("RGBColor"), desc8);
    desc6.putObject(stringIDToTypeID("strokeStyleContent"), stringIDToTypeID("solidColorLayer"), desc7);
    desc6.putDouble(stringIDToTypeID("strokeStyleResolution"), 72);
    desc2.putObject(stringIDToTypeID("strokeStyle"), stringIDToTypeID("strokeStyle"), desc6);
    desc1.putObject(charIDToTypeID('Usng'), stringIDToTypeID("contentLayer"), desc2);
    desc1.putInteger(charIDToTypeID('LyrI'), 53);
    executeAction(charIDToTypeID('Mk  '), desc1, DialogModes.NO);
  };

Thank you,

Damian

TOPICS
Actions and scripting, How to, Make It, Windows

Views

619

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Adobe Community Professional , May 20, 2021 May 20, 2021
Remove unnecessary parameters function Circle() { var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putClass(stringIDToTypeID("contentLayer")); desc1.putReference(charIDToTypeID('null'), ref1); var desc2 = new ActionDescriptor(); var desc3 = new ActionDescriptor(); var desc4 = new ActionDescriptor(); desc4.putDouble(charIDToTypeID('Rd '), 255); desc4.putDouble(charIDToTypeID('Grn '), 255); desc4.putDouble(charIDToTypeID('Bl '...

Likes

Translate

Translate
Adobe Community Professional , May 20, 2021 May 20, 2021
Clean SL is a must have script for dummies like myself... r-bin is not a dummy he know how to code action manager code not only to execute action steps like scriptliste he knows how the retrieve results of Photoshop command execution,

Likes

Translate

Translate
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

I do not know if there is a simpler way.  I do  know that  function that is scriptlistener's logged action manager code is not a function I would use it is fixed like an action step..  You can not pass  parameters like origin, radius, color fill blend etc.

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

If you search this forum you should be able to find a "Clean SL.jsx" Photoshop script that can help you process your scriptlistemer log and clean the code, Create Javascript Photoshop functions that are more usable you will be able to pass parameters.

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Clean SL is a must have script for dummies like myself...

 

r-bin is not a dummy he know how to code action manager code not only to execute action steps like scriptliste he knows how the retrieve results of Photoshop command execution,

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Remove unnecessary parameters

 

 

function Circle() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putClass(stringIDToTypeID("contentLayer"));
    desc1.putReference(charIDToTypeID('null'), ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(charIDToTypeID('Rd  '), 255);
    desc4.putDouble(charIDToTypeID('Grn '), 255);
    desc4.putDouble(charIDToTypeID('Bl  '), 255);
    desc3.putObject(charIDToTypeID('Clr '), stringIDToTypeID("RGBColor"), desc4);
    desc2.putObject(charIDToTypeID('Type'), stringIDToTypeID("solidColorLayer"), desc3);
    var desc5 = new ActionDescriptor();
    desc5.putUnitDouble(charIDToTypeID('Top '), charIDToTypeID('#Pxl'), 124);
    desc5.putUnitDouble(charIDToTypeID('Left'), charIDToTypeID('#Pxl'), 164);
    desc5.putUnitDouble(charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), 268);
    desc5.putUnitDouble(charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), 308);
    desc2.putObject(charIDToTypeID('Shp '), charIDToTypeID('Elps'), desc5);
    desc1.putObject(charIDToTypeID('Usng'), stringIDToTypeID("contentLayer"), desc2);
    executeAction(charIDToTypeID('Mk  '), desc1, DialogModes.NO);
  };

 

 

UPD.

Or

// create path
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("path"), stringIDToTypeID("workPath"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"),    200);
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"),   400);
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"), 500);
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"),  700);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("ellipse"), d1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);


// create fill layer
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("contentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID("red"),   100);
d3.putDouble(stringIDToTypeID("green"), 150);
d3.putDouble(stringIDToTypeID("blue"),  200);
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("solidColorLayer"), d2);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 21, 2021 May 21, 2021

Copy link to clipboard

Copied

LATEST

Thank you JJMack and r-bin you both have very helpful information and that is why I have chosen two correct answers.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines