This content has been marked as final. Show 14 replies
See here http://www.adobeforums.com/webx/.59b50662/1
i appologise it took me so long to say
T H A N X - G R E A T T I P
i built on your nice little script lerning the commands and created a little variation to suit better to my workflow...
to anybody interested here i post the scripts - they work fine you can assign your shortcuts:
1) script to copy HEIGHT and WIDTH of selected object
if (app.selection.length < 1)
var frameCOPY = app.selection;
var gbCOPY = frameCOPY.geometricBounds;
var wCOPY = gbCOPY - gbCOPY;
var hCOPY = gbCOPY - gbCOPY;
2) script to apply copied HEIGHT and WIDTH onto a selected object
if (app.selection.length < 1)
var framePASTE = app.selection;
var gbPASTE = framePASTE.geometricBounds;
var new_y2 = gbPASTE+hCOPY
var new_x2 = gbPASTE+wCOPY
gbRESULT=new Array (gbPASTE,gbPASTE,new_y2,new_x2)
still this is not perfect
id love the script to respect the currentlly selected refrence point and always change the size TOWARDS THE CURRENTLLY SELECTED REFERENCE POINT
right now the script always resizes TOWARD TOP-LEFT CORNER... id love to resize towards any given refrence point i have currentlly selected
I don't think you can get the currently selected reference point.
:((( are you sure ?
Yes you can get it. Let me see if I can remember...
anybody any suggestions which commands to use ?
var myProxy = app.activeWindow.transformReferencePoint;
Ah yes, it's a window property because there's one per window in the UI.
hmm but the tricky part still lays ahead given you can calculate height and width of object1 from a set of geometricBoundaries (eg. 10, 10, 60, 50)
and after some simple math you can transform object2 to have same height and width as object1... but the hight and width will always originate from TOP-LEFT corner unless you use some different routine than geometricBounds[y1,x1,y2,x2]
what other ways/commands are there for changing height and width of object to specific milimeters while always originating from different reference point ??? geometricBounds is probably hardcoded to TOP-LEFT origin
> var myProxy = app.activeWindow.transformReferencePoint;
Well well well -- that's useful, thanks.
>what other ways/commands are there for changing height and width ...
You could delve into transform matrices (though you shouldn't if you want to stay sane). The easier way, though, is to start calculating from a different point in the geometricBounds.
all right iam giving up iam starting to loose my hair
i spent 4 hours trying to figure out the way to get X and Y coordinates of an object or point using transformationMatrices and transformationResolve
this is my problem:
1) i select an object
2) i choose a transformation anchor point of the object
3) my Control Palete reads X and Y coordiantes of the currentlly selected anchor point of the object...
NOW how do i get these numbers as variables to use in my script ?? from what internal values does INDD calculate these X and Y coordinates ?
it CANT use geometricBounds command because this command always returns TOPLEFT and BOTTOMRIGHT corners but i want to choose my anchor point and get the location of the SELECTED anchor point... just like my control palette show me when i cycle through anchor points
i spent 3 hours figuring out this "resolve" command but its a rocket science and i wasnt able to completelly decipher why it returns numbers so off the documents rulers space...
MyAnchorXYLocation=app.selection.resolve(MySelectedAnchor, CoordinateSpaces.pasteboardCoordinates, true)
nevermind is there any fundamentally different aproach to get a number showing in the X and Y location boxes of Control Palette when i switch between different object's anchor points ??
What I'd do is use geometricBounds like this:
1. Determine the coordinates of the anchored point on your second object (the one you're resizing).
2. Set the geometricBounds of the second object to those of the first.
3. Move the second object by the difference between where you want it and where it is.
well point number one
"Determine the coordinates of the anchored point on your second object"
is what drives me crazy... i can see the coordinates of anchor point in indesign Control Palette but i dont know how to get these values into my script :) these X and Y coordinates naturally change when i cycle through different anchor point of the same object...
while working with anchor point coordinates comes absolutlly natural in indesign it is a tough problem for me to get these values into my scripts...
this "X and Y coordinates of current anchor point" problem became more confusing than the actual resizing which i figured out and already succesfully solved through percentage scale (new_object is resized to percentual width and height of original_object and the transformation conforms to current selected anchor point)...
resizing to anchor point was a relativelly quick fix, but how to get the X and Y coordinates of any of 9 anchor point of an object ???
If the geometric bounds are [t, l, b, r] then:
top left is [l,t]
top middle is [(l+r)/2, t]
top right is [r, t]
middle left is [l, (t+b)/2]
middle is [(l+r)/2, (t+b)/2]
middle right is [r, (t+b)/2]
bottom left is [l,b]
bottom middle is [(l+r)/2, b]
bottom right is [r,b]
Simple geometry. Unless, the items have been rotated and particularly if they've been rotated by different amounts. Then it's much harder.