Skip to main content
Known Participant
June 13, 2008
Question

JS CS3 Change geometricBounds

  • June 13, 2008
  • 3 replies
  • 495 views
Hi

When I run:
app.selection[0].geometricBounds = [0,0,10,10];
everything works as expected.

I only want to change the width so I tried:
app.selection[0].geometricBounds[3] += 10;

or

app.selection[0].geometricBounds[3] = app.selection[0].geometricBounds[3] + 10;
nothing changes and no error message appears.

I solved it in the following clumsy way eventually:

a = app.selection[0].geometricBounds[0];
b = app.selection[0].geometricBounds[1];
c = app.selection[0].geometricBounds[2];
d = app.selection[0].geometricBounds[3] + 10;

app.selection[0].geometricBounds = [a,b,c,d];

So it finally kind of works but it leaves me scratching my head. Is this really the way to do it?

Thanks for clarification
weller
This topic has been closed for replies.

3 replies

Known Participant
June 13, 2008
Thanks Dave
It makes sense now.
Inspiring
June 13, 2008
PS: I tend not to use the += operator because it just doesn't feel intuitive that it has the effect it does. That second line could have been:

myBounds[3] += 10;

Dave
Inspiring
June 13, 2008
I would do it this way:

myBounds = app.selection[0].geometricBounds;
myBounds[3] = myBounds[3] + 10;
app.selection[0].geometricBounds = myBounds;

The point is that because the property is an array, you must set it with an array -- if you try to manipulate a member of the array, what happens is that ExtendScript creates a temporary version of the array, manipulates that and it is left hanging out there with no effect.

Dave