PDA

View Full Version : noop loop error


ltethe
09-10-2010, 09:17 PM
So this is just a real basic script to wrap each object selected into a group node.

Problem is that I get:

Group1
-Group2
--Group3
---Group4
----sphere01
----sphere02
----sphere03
----sphere04

When the output I want is:

Group1
-sphere01

Group2
-sphere02

Group3
-sphere03

Group4
-sphere04


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

//insert Selection
for($each in $selectionSet){

group;
xform -os -piv 0 0 0;
}


Thanks for the assist all, I'm missing something super basic.

shcmack
09-10-2010, 10:36 PM
This one select's each object before it creates the group, should do the trick.

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

//insert Selection
for($each in $selectionSet)
{
select $each;
group;
xform -os -piv 0 0 0;
}

ewerybody
09-13-2010, 01:55 PM
ehmm... I don't know how much nodes we are talking here but performancewise selecting in a loop is always bad. group can work on a given object anyway:

{
string $selectionSet[] = `ls -sl`;
string $group;
for($each in $selectionSet)
{
$group = group($each);
xform -os -piv 0 0 0 $group;
}
}

CGTalk Moderation
09-13-2010, 01:55 PM
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.