Copy link to clipboard
Copied
Scoured the forums for a script to flip the width and height frame values to no avail. In other words, make the width value the height’s and the height value the width’s.
Attempting to accomplish this without rotating in order to keep the “top of frame indicator” (i.e. the solid small box on the frame) on top of the frame where it defaults to, hence keeping the proper default orientation throughout. That’s the key.
In the meantime will attempt to scour my dimension scripts to see if I can possibly throw something together.
Although it seems dimension scripts can get pretty hairy.
Thanks all for any leads.
Take a frame as such:

And maintain the dimension while transposing the Width and Height to result in the below (without rotating):

Hi,
In your first try, you used s.length. selection is a single object. so it does not have length property.

In your 2nd try, you used g.length. g is geometric bounds and the selection is a single object but you used s

Process :
1. Selection should be multiple. ie., Rectangle
2. loop it (rectangle) and proceed your flow.
var s = app.selection; // Selection of multiple rectangle
for(var sCnt = 0; sCnt < s.length; sCnt++)
{
...
Copy link to clipboard
Copied
A simplistic script that assumes that a non-rotated, non-sheared rectangle is involved would look like this:
// Select a rectangle and run the script to flip its width and height.
s = app.selection[0];
g = s.geometricBounds;
s.geometricBounds = [g[0], g[1], g[0] + (g[3] - g[1]), g[1] + (g[2] - g[0])];
That might be all you need in your particular case...
Copy link to clipboard
Copied
This works great on a single selection.
I’m attempting to loop it and not having any luck, so as to grab multiple selections and have it work on all selected.
The below snippet throws the following error (screenshot below):
// Select a rectangle and run the script to flip its width and height.
var s = app.selection
; var g = s.geometricBounds;
for(var n=0;n<s.length;n++)
{
s.geometricBounds = [g[0], g[1], g[0] + (g[3] - g[1]), g[1] + (g[2] - g[0])];
};

Copy link to clipboard
Copied
Also tried the below, with the following error (screenshot below).
But previously, without the “
Seems I’m getting close, but don’t know enough about extend script, or looping, to bring it home.
// Select a rectangle and run the script to flip its width and height.
var s = app.selection[0];
var g = s.geometricBounds;
for(var n=0;n<g.length;n++)
{
s
.geometricBounds = [g[0], g[1], g[0] + (g[3] - g[1]), g[1] + (g[2] - g[0])]; };

Copy link to clipboard
Copied
Hi,
In your first try, you used s.length. selection is a single object. so it does not have length property.

In your 2nd try, you used g.length. g is geometric bounds and the selection is a single object but you used s

Process :
1. Selection should be multiple. ie., Rectangle
2. loop it (rectangle) and proceed your flow.
var s = app.selection; // Selection of multiple rectangle
for(var sCnt = 0; sCnt < s.length; sCnt++)
{
var cObj = s[sCnt];
var g = cObj.geometricBounds;
cObj.geometricBounds = [g[0], g[1], g[0] + (g[3] - g[1]), g[1] + (g[2] - g[0])];
}
Try this..
Copy link to clipboard
Copied
This works awesomely now.
After staring at this for some time, i want to clarify:
• this snippet contains 4 variables, correct (s, g, sCnt, cObj)?
• What made you name sCnt, and cObj, as such? Just attempting to figure out your train of thought. Obj is short for object, right. Cnt, is that short for container or center?
• s[sCnt] is similar to certain loop setups I’ve come across, i.e. sel
I would have never came up with this. I knew it would be different than any other loop I’ve come across so far.
In any event, thanks again, really appreciate it.
Copy link to clipboard
Copied
Hi,
I used those variable to hold the values.
s - Selection objects
g - variable holds the bounds value (already used)
sCnt - Selection Count increament of for loop
cObj - Current selection object. Instead of this, you can use directly use s[sCnt] as you said.
You can use it as your own way.
Copy link to clipboard
Copied
I’m gonna pretend I understand 100%.
But really it’s more like 60%.
Thanks again.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now