PDA

View Full Version : How to get around with |-problem (Parenting)


BluesmanI
04-16-2008, 11:26 PM
Hi guys,

i have a little problem. Looks like this.

At first i create objects, throw their names via "ls -sl" in separate arrays.

polyCube -n "testPlate";
string $plates[] = `ls -sl`;


Then i group them and finally give the newly created group some attributes based on some of the attributes of the grouped objects.

group -n "testGroup01";
addAttr -ln "Length" -k true -dv (`getAttr ($plates[0] + ".scaleZ")`);



Well, works fine for the first run. If i run it a second time, i get an error (no object matches name |testPlate.scaleZ).

I know that | is kind of parenting operator. But doesn't |xxx mean that it is parented to the world, which means it normally should work like in the first run?


Thanx in advance
Blues

greatPumpkin
04-17-2008, 08:34 AM
it's because your throwing the plane in an array, and then grouping it- so before grouping it's full path name is '|plane' , then after grouping it's called '|testGroup01|plane', your variables will not update on the fly so maya can't find the object when you try and get the attribute later.

Try re-working your script so that each plane has a definitive unique name, maya will generally give you the shortest name by default, so you won't get the '|' problems if your names are unique. Also, most commands return their output anyway, so you don't need to do an `ls -sl` afterwards to put them in arrays-

i.e.

for($i = 0;$i < 5;$i++)
{
string $plate[] = ` polyCube -ch 0-n ("testPlate" + $i)`;
addAttr -ln "Length" -k true -dv (`getAttr ($plate[0] + ".scaleZ")`);
string $grp = `group -n ("testGroup" + $i) $plate[0]`;
}


also, if you want an easier, though more fragile solution, your script should work fine if you add the attribute to the cube before you group it.

damat
04-17-2008, 12:40 PM
also you can use -l flag in ls command:
ls -sl -l will return // Result: |group1|pPlane1

BluesmanI
04-17-2008, 10:46 PM
Thanx for all the hints. Will try them immediately.

@greatPumpkin:
... your script should work fine if you add the attribute to the cube before you group it.

The problem is, I have to add the attribute to the group, not to one of the members. My script will look for the group names and then "extract" their custom attributes. ;-)

CGTalk Moderation
04-17-2008, 10:46 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.