Home/Support/

Forums

2 Replies Last post: Mar 28, 2008 4:05 PM by (david_bythell)  
User 2 posts since
Aug 20, 2007
Currently Being Moderated

Mar 28, 2008 6:59 AM

Circles with Javascript

I'm attempting to script the drawing a number of circles and doughnut type shapes on a document. Is there any way of doing this directly from within a script, rather than recording the action with the script listener, then modifying the output? E.g. is there an ellipse or circle function that I can program directly?

Look forward to any comments

David
Paul Riggott Participant 757 posts since
Dec 4, 2008
Currently Being Moderated
1. Mar 28, 2008 10:31 AM in response to: (david_bythell)
Re: Circles with Javascript
Here you go.
make sure you change ('T ') to T and Three Spaces!
Paul.

var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
Circle(0,0,300,300);
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;

function Circle(Top,Left,Bottom,Right) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };

var desc3 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( cTID('Chnl'), cTID('fsel') );
desc3.putReference( cTID('null'), ref1 );
var desc4 = new ActionDescriptor();
desc4.putUnitDouble( cTID('Top '), cTID('#Pxl'), Top );
desc4.putUnitDouble( cTID('Left'), cTID('#Pxl'), Left );
desc4.putUnitDouble( cTID('Btom'), cTID('#Pxl'), Bottom );
desc4.putUnitDouble( cTID('Rght'), cTID('#Pxl'), Right );
desc3.putObject( cTID('T '), cTID('Elps'), desc4 );
desc3.putBoolean( cTID('AntA'), true );
executeAction( cTID('setd'), desc3, DialogModes.NO );
};

More Like This

  • Retrieving data ...