Copy link to clipboard
Copied
Hi how are the parameters related in the transform operation. I had guessed the parameter as marked but not sure how they are related in photoshop. How does the change of one parameter impact other. How is the relation.
function Distort()
{
var id3535 = charIDToTypeID( "Trnf" );
var desc593 = new ActionDescriptor();
var id3536 = charIDToTypeID( "null" );
var ref21 = new ActionReference();
var id3537 = charIDToTypeID( "Lyr " );
var id3538 = charIDToTypeID( "Ordn" );
var id3539 = charIDToTypeID( "Trgt" );
ref21.putEnumerated( id3537, id3538, id3539 );
desc593.putReference( id3536, ref21 );
var id3540 = charIDToTypeID( "FTcs" );
var id3541 = charIDToTypeID( "QCSt" );
var id3542 = charIDToTypeID( "Qcsa" );
desc593.putEnumerated( id3540, id3541, id3542 );
var id3543 = charIDToTypeID( "Ofst" );
var desc594 = new ActionDescriptor();
var id3544 = charIDToTypeID( "Hrzn" );
var id3545 = charIDToTypeID( "#Pxl" );
desc594.putUnitDouble( id3544, id3545, 0.00000 ); //hrzn //horizontal x
var id3546 = charIDToTypeID( "Vrtc" );
var id3547 = charIDToTypeID( "#Pxl" );
desc594.putUnitDouble( id3546, id3547, 0.00000 ); //vrtc verticulo
var id3548 = charIDToTypeID( "Ofst" );
desc593.putObject( id3543, id3548, desc594 );
var id3549 = charIDToTypeID( "Wdth" ); //wdth
var id3550 = charIDToTypeID( "#Prc" );
desc593.putUnitDouble( id3549, id3550, 100.00 ); /* Scale */
var id3551 = charIDToTypeID( "Hght" ); //hght
var id3552 = charIDToTypeID( "#Prc" ); //#prc
desc593.putUnitDouble( id3551, id3552,100.00 );
var id3553 = charIDToTypeID( "Skew" ); //-------
var desc595 = new ActionDescriptor();
var id3554 = charIDToTypeID( "Hrzn" );
var id3555 = charIDToTypeID( "#Ang" );
desc595.putUnitDouble( id3554, id3555, 0.000000 ); //#ang
var id3556 = charIDToTypeID( "Vrtc" );
var id3557 = charIDToTypeID( "#Ang" );
desc595.putUnitDouble( id3556, id3557,0.000000 ); //#ang
var id3558 = charIDToTypeID( "Pnt " );
desc593.putObject( id3553, id3558, desc595 );
var id3559 = charIDToTypeID( "Angl" );
var id3560 = charIDToTypeID( "#Ang" );
desc593.putUnitDouble( id3559, id3560, 0.000000 ); //angl (body angle)
var id3561 = charIDToTypeID( "Usng" );
var desc596 = new ActionDescriptor();
var id3562 = charIDToTypeID( "Hrzn" );
var id3563 = charIDToTypeID( "#Prc" );
desc596.putUnitDouble( id3562, id3563, 0.00000 ); // hrzn #Prc skew
var id3564 = charIDToTypeID( "Vrtc" );
var id3565 = charIDToTypeID( "#Prc" );
desc596.putUnitDouble( id3564, id3565, .000000 ); //vrtc
var id3566 = charIDToTypeID( "Pnt " );
desc593.putObject( id3561, id3566, desc596 );
executeAction( id3535, desc593, DialogModes.NO );
}
Thankyou
I know of no way to to set the handles directly. As Xbytor said, most scripters I know either do the transform in the GUI with the scriptlistner plugin running to get the settings or set the DialogModes to DialogModes.ALL and let the user of the script do the transform.
If you really want to understand the transform descriptor below is my notes on the descriptor. Note in may not run as is. It's just for comments and does not include any warp settings.
...var desc = new ActionDescriptor();
Copy link to clipboard
Copied
The simplest thing to do is to do a transform and save the JS for it.
Do another different transform and compare the results. That's how
I've done it in the past and it works pretty well, but there is no central
repository of information about these settings that I know of.
-X
Copy link to clipboard
Copied
Thanks xbytor2.
Are there methods for the bounds of a transform selection to access its coordinates, or position.
Copy link to clipboard
Copied
I'm not sure what you are asking.
If you want the bounds of the selection after transforming the selection just get the selection bounds after the transform.
If you want the bounds of the new transformed area of a layer where only the selected part of the layer was transformed, get the selection bounds after thransform.
If you want the bounds of the new transformed area of a layer where the entire layer was transformed, get the layer bounds after thransform.
With any of those cases the bounds may be larger than the document bounds. In that case expect to see negitive numbers in the bounds.
Copy link to clipboard
Copied
Like the first case, for transforming by just giving new bounds(the four end points) instead of setting the parameters given in the script.
Copy link to clipboard
Copied
I know of no way to to set the handles directly. As Xbytor said, most scripters I know either do the transform in the GUI with the scriptlistner plugin running to get the settings or set the DialogModes to DialogModes.ALL and let the user of the script do the transform.
If you really want to understand the transform descriptor below is my notes on the descriptor. Note in may not run as is. It's just for comments and does not include any warp settings.
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), icharIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc.putReference( charIDToTypeID( "null" ), ref );
// 0ne of the 9 anchor points in the option bar or "Qcsi" for custom anchor
desc.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ), charIDToTypeID( "Qcsa" ) );
/* this block is only needed for "Qcsi"
var pointDesc = new ActionDescriptor();
pointDesc.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Pxl" ), 50.000000 );
pointDesc.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Pxl" ), 50.000000 );
desc.putObject( charIDToTypeID( "Pstn" ), charIDToTypeID( "Pnt " ) pointDesc );
*/
var offsetDesc = new ActionDescriptor();
// + or - amount to translate in pixels.
// activeDocument.selection.translate( new UnitValue( 50, 'px' ), new UnitValue( 50, 'px' ), AnchorPosition.MIDDLECENTER );
// or activeDocument.selection.translate( new UnitValue( 50, 'px' ), new UnitValue( 50, 'px' ), AnchorPosition.MIDDLECENTER );
offsetDesc.putUnitDouble( charIDToTypeID( "Hrzn" ), icharIDToTypeID( "#Pxl" ) 50.000000 );
offsetDesc.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Pxl" ), 50.000000 );
desc.putObject( charIDToTypeID( "Ofst" ), charIDToTypeID( "Ofst" ), offsetDesc );
// + or - amount to scale in percent.
// activeDocument.selection.resize( 110, 110 )
// activeDocument.activeLayer.resize( 110, 110 )
desc.putUnitDouble( charIDToTypeID( "Wdth" ), charIDToTypeID( "#Prc" ), 110.000000 );
desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100.000000 );
// + or - 90 degree to skew. no DOM API method.
var skewDesc = new ActionDescriptor();
skewDesc.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Ang" ), 50.000000 );
skewDesc.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Ang" ), 0.000000 );
desc.putObject( charIDToTypeID( "Skew" ), charIDToTypeID( "Pnt " ), skewDesc );
// 0 to 359 degree to rotate
// activeDocument.selection.rotate( 90,AnchorPosition.MIDDLECENTER );
// activeDocument.activeLayer.rotate( 90, AnchorPosition.MIDDLECENTER );
desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "Angl" ), 90.000000 );
executeAction( charIDToTypeID( "Trnf" ), desc, DialogModes.NO );
Everything seems straight forward is you just want to do one thing such as rotate or translate. It also seems to be ok if you want to translate, scale, rotate, and skew in just one direction.
Things get strange when you try to do everything. The scriptlistner output now longer matches the settings in the option bar and those changes vary with which anchor point is used.
I gave up long ago trying to understand this and now follow the suggestion to use different recorded transforms or let the user do it themselves.
Copy link to clipboard
Copied
Thanks for the replys.
what is the 'Usng' tag.
var id3561 = charIDToTypeID( "Usng" );
Thankyou.
Copy link to clipboard
Copied
The string version of that ID is 'using'. It's most often see with putObject and putReference. It can sometimes be seen with putEnumerated.
I see that I left it off the angle part of my example, along with other errors. As I noted that example may not work. Because of the way the scriptlistner output can be different from the options bar I had to put several together to include everything.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now