-
1. Re: Simple Square Up script for Windows
John Hawkinson Jul 1, 2013 5:54 AM (in response to E Diane King)Hi, Diane.
Step one is to translate the Applescript coding back into human-readable Applescript, which you do by pasting into the Applescript Editor and hitting Compile. You get this:
tell application "Adobe InDesign CS6" set {a, b, c, d} to geometric bounds of selection set entire path of path 1 of selection to {{b, a}, {d, a}, {d, c}, {b, c}} end tellStep two:
Here is the translation into Javascript. Note that in JavaScript, arrays (geometric bounds and paths) start counting at zero, rather than one, so "path 1" becomes "paths[0]", etc.; also, we refer to "app.selection[0]" rather than "selection", because there can be multiple selections, and AppleScript lets you say "selection" to mean the first one, but JavaScript requires you to be explicit:
var abcd, a, b, c, d; abcd = app.selection[0].geometricBounds; a=abcd[0]; b=abcd[1]; c=abcd[2]; d=abcd[3]; app.selection[0].paths[0].entirePath = [ [b,a], [d,a], [d,c], [b,c] ];
I'm not 100% sure what your test case is, so if it turns out the order of numbers in the entirePath array is different between Javascript and AppleScript, then something might go wrong. I don't think so, but please od test it.
-
2. Re: Simple Square Up script for Windows
E Diane King Jul 1, 2013 6:33 AM (in response to John Hawkinson)Thanks, John! That worked. I appreciate your expertise and willingness to help and even instruct. Still not sure I could write a Javascript, but I at least understand better the syntax from your explanation.
-
3. Re: Simple Square Up script for Windows
John Hawkinson Jul 1, 2013 6:44 AM (in response to E Diane King)You're welcome. It wasn't intended as a full-out tutorial, but I did want to explain the obvious changes that might seem odd if you didn't know why they were the case...



