Referencing objects in containers
Posted: 05 Dec 2013 10:40
I'm struggling with syntax trying to generically access objects in a container. Here's the setup:
I have 6 containers (named OP1-OP6). Each container has the same set of objects inside it, including a Breakpoint object named Env.
I have a script that manipulates the container called makeBig(opObj). I pass in the container object and do stuff like change the rectangle coordinates and size.
This is all fine. However, I want to be able to manipulate the Breakpoint size and move other objects around in that same function. The hardcoded syntax would be something like:
tmp = findobject('OP1.Env');
tmpRect = getobjectrect(tmp);
tmpRect[2] += 30;
tmpRect[3] += 60;
setobjectrect(tmp, tmpRect);
What I really want is a generic way to call findobject() like
tmp=findobject(opObj.'env'); //which doesn't work
I tried various combinations of converting things from arrays to strings and then attempting to build up a longer string with no success. I feel like I'm missing something obvious, but I can't figure out exactly how to generically address the object inside the container. Is there a way?
(I can do other things like make a separate call to a script that manipulates Env's and passing in the container.breakpoint reference or a series of if () conditions comparing the object name against known container names and then getting the objects inside, but I feel there's a simpler solution that I'm missing).
I have 6 containers (named OP1-OP6). Each container has the same set of objects inside it, including a Breakpoint object named Env.
I have a script that manipulates the container called makeBig(opObj). I pass in the container object and do stuff like change the rectangle coordinates and size.
This is all fine. However, I want to be able to manipulate the Breakpoint size and move other objects around in that same function. The hardcoded syntax would be something like:
tmp = findobject('OP1.Env');
tmpRect = getobjectrect(tmp);
tmpRect[2] += 30;
tmpRect[3] += 60;
setobjectrect(tmp, tmpRect);
What I really want is a generic way to call findobject() like
tmp=findobject(opObj.'env'); //which doesn't work
I tried various combinations of converting things from arrays to strings and then attempting to build up a longer string with no success. I feel like I'm missing something obvious, but I can't figure out exactly how to generically address the object inside the container. Is there a way?
(I can do other things like make a separate call to a script that manipulates Env's and passing in the container.breakpoint reference or a series of if () conditions comparing the object name against known container names and then getting the objects inside, but I feel there's a simpler solution that I'm missing).