One of the things I was working on (before my computer got knicked!

) was a library of scipting commands taken from the ScriptListner listings.
This
post by babedieboe reminded me ....
Basically if you turn the "id.." stuff into constants and try to give a useful name to the "desc..." stuff you can reorganize the commands into a more understandable, and re-usable format.
The script (listing) posted comes out as....
Quote:
|
Originally Posted by NewScript // define constants
// ======================================================
var MAKE = charIDToTypeID( "Mk " ); // Make new object
var NEWO = charIDToTypeID( "Nw " ); // New object
var POSN = charIDToTypeID( "Pstn" );// Position
var NPXL = charIDToTypeID( "#Pxl" );// Number of Pixels
var ORNT = charIDToTypeID( "Ornt" );// Orientation
var VERT = charIDToTypeID( "Vrtc" );// Vertical
var HORZ = charIDToTypeID( "Hrzn" );// Horizontal
var GUID = charIDToTypeID( "Gd " ); // Guide
// set guidelines at 50% on X & Y
// =======================================================
var doc = app.activeDocument;
var GUIDE = new ActionDescriptor();
var PLACE = new ActionDescriptor();
PLACE.putUnitDouble( POSN, NPXL, doc.width/2 );
PLACE.putEnumerated( ORNT, ORNT, VERT );
GUIDE.putObject( NEWO, GUID, PLACE );
executeAction( MAKE, GUIDE, DialogModes.NO );
// =======================================================
var GUIDE = new ActionDescriptor();
var PLACE = new ActionDescriptor();
PLACE.putUnitDouble( POSN, NPXL, doc.height/2 );
PLACE.putEnumerated( ORNT, ORNT, HORZ );
GUIDE.putObject( NEWO, GUID, PLACEMENT );
executeAction( MAKE, GUIDE, DialogModes.NO );
// end guidelines========================================= |
Unfortunately I can't test this (don't have scripts here), but I think you'll get the idea.
This "make guide" command is just an example, if you do the same for the "make line" command, then the fun starts!!
byRo