byRo
01-04-2005, 09:13 AM
One of the things I was working on (before my computer got knicked! :cry: ) was a library of scipting commands taken from the ScriptListner listings.
This post (http://www.retouchpro.com/forums/showpost.php?p=78054&postcount=9) 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....
// 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
This post (http://www.retouchpro.com/forums/showpost.php?p=78054&postcount=9) 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....
// 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