Skip to main content
smithcgl9043167
Inspiring
June 24, 2019
Question

Resize path!

  • June 24, 2019
  • 1 reply
  • 537 views

Hello! How to resize the active path to document boundaries?

Thank you

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
June 24, 2019

Use action manager code to transform the path. It easy to get the documents width and height.  However the Path bounds is a different story.  You will most  likely need that to calculate the vales need to be used with transform.  You can create a selection for the path and get the bounds of that selection. You can get the control points in the path however a path cam be any shape and have many  points.  I would think its the path bounds you need to work from.

The X and y delta of the path center point move to the center of the canvas and the  width and height resize in percentage.

// =======================================================

transform(631, 202.5, 929.166667, 450.520833);

function transform(horizontal, vertical, width, height) {

var descriptor = new ActionDescriptor();

var descriptor2 = new ActionDescriptor();

var reference = new ActionReference();

reference.putEnumerated( stringIDToTypeID( "path" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));

descriptor.putReference( charIDToTypeID( "null" ), reference );

descriptor.putEnumerated( stringIDToTypeID( "freeTransformCenterState" ), stringIDToTypeID( "quadCenterState" ), stringIDToTypeID( "QCSAverage" ));

descriptor2.putUnitDouble( stringIDToTypeID( "horizontal" ), stringIDToTypeID( "pixelsUnit" ), horizontal );

descriptor2.putUnitDouble( stringIDToTypeID( "vertical" ), stringIDToTypeID( "pixelsUnit" ), vertical );

descriptor.putObject( stringIDToTypeID( "offset" ), stringIDToTypeID( "offset" ), descriptor2 );

descriptor.putUnitDouble( stringIDToTypeID( "width" ), stringIDToTypeID( "percentUnit" ), width );

descriptor.putUnitDouble( stringIDToTypeID( "height" ), stringIDToTypeID( "percentUnit" ), height );

executeAction( stringIDToTypeID( "transform" ), descriptor, DialogModes.NO );

}

That action manager corde was for this transform

JJMack