PDA

View Full Version : mapping multiple objects


bendingiscool
05-19-2008, 07:22 PM
I have a bunch of cubes and I would like to write a script that does an automatic map on them. I tried this after selecting all the cubes...

string $polyBlocksArray[] = `ls -sl`;

for ($myObject in $polyBlocksArray) {

polyAutoProjection;

}

I get an error saying "Doesn't work with multiple objects selected". How would I go about getting the loop to go through them one at a time and map that way?

Many thanks in advance
Chris

RetroAnimator
05-19-2008, 09:02 PM
Since the name of object isn't provided, the command polyAutoProjection tries to perform on what you selected: All cubes in your scene for every single cycle of your loop, which ends up with the error "doesn't work with multiple objects selected".

You can either select the object in the loop before projecting:

string $polyBlocksArray[] = `ls -sl`;
for ($myObject in $polyBlocksArray) {
select $myObject;
polyAutoProjection;
}

Or simply, specify the name of object,

string $polyBlocksArray[] = `ls -sl`;
for ($myObject in $polyBlocksArray)
polyAutoProjection $myObject;

GiantG
05-19-2008, 09:46 PM
You have to select you obj first and do it for every Obj individually.
Thats what the loop is for. Otherwise you wouldn't need a loop at all

string $polyBlocksArray[] = `ls -sl`;
for ($myObject in $polyBlocksArray)
{
select $myObject;
polyAutoProjection;
}

cheerz...

bendingiscool
05-19-2008, 09:59 PM
Thanks Giant!!

NaughtyNathan
05-20-2008, 10:33 AM
always try to avoid selecting things inside a script. It adds unnecessary work which makes your script run slower (in theory, maybe not noticable in practice, depending on the number of objects/selections) but also has a negative impact on the internal mechanisms controlling script undoing and scene state controlling. Always simply refer to the objects you are working on in the command and then no state switching or manipulation has to be done. (and your script will be shorter!) ;)

so, as RetroAnimator said:

polyAutoProjection $myObject;

is infinitely preferable to the "select" method, even if you can't immediately discern the difference!

:nathaN

CGTalk Moderation
05-20-2008, 10:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.