Greetings everyone,
I'm struggling with something and maybe someone has an idea how I can pull this one off.
I have 2 objects (lets say 2 rectangles) and I need to align one of them (vertically or horizontally) relatively to the other one.
Anyone know how this can be done? using the tools it would be easy but, how can this be done using a script?
Many thanks in advance
- Miguel Pinto
[How To] Align objects through script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: [How To] Align objects through script
Hi Miguel,
The left, right, top, bottom, width, height, rect and loc of an object are all settable properties.
If you have two rectangles at the correct vertical position on the card and want to align the two to the same horizontal position you can do something like
If they are different widths and you want to align them according to the centre you will have to do a little construction of the new co-ordinates
Hope that helps
The left, right, top, bottom, width, height, rect and loc of an object are all settable properties.
If you have two rectangles at the correct vertical position on the card and want to align the two to the same horizontal position you can do something like
Code: Select all
set the left of graphic "rectangle2" to the left of graphic "rectangle1"
Code: Select all
put item 1 of the loc of graphic "rectangle1" into item 1 of tNewLoc
put item 2 of the loc of graphic "rectangle2" into item 2 of tNewLoc
set the loc of graphic "rectangle2" to tNewLoc
Re: [How To] Align objects through script
Cool, It was exactly this I was looking for.
I had read something about the left, right, etc... but didn't know that I could use it like that
Many thanks!
- Miguel
I had read something about the left, right, etc... but didn't know that I could use it like that
Many thanks!
- Miguel