View Full Version : NOOOOB Nightmare
JellyFire 12-22-2005, 06:11 AM I should be able to do this, maybe it's a brain lock,
maybe it's cos It's 7am and I can't get to sleep :)
But I started scripting something thinking it was going
to be really easy and instead had to mess around with
this for ages!!! All I want to do at this stage is print
the Shapes Name of the selected object.
so.
ls -flatten -sl -s;
should do right?
this is what I'm using, tried various combinations and
nothing works.
string $shapeName[] `ls -flatten -sl -s`;
print $shapeName;
if I take the "-s" out it will print the selected object name.
put it in and it prints nothing!!!
:banghead: S = Sums it up!!!
Thanks for any tips.
Jellyfire.
|
|
swardson
12-22-2005, 07:04 AM
ok, so you dont want to use flatten here. You want to use that when you have selected multiple components and you want to list them seperately rather than the default grouping maya does to them. ie: pCube.vtx[1] pCube.vtx[2] rather than pCube.vtx[1:8]
as far as getting an objects shape node... the best way I have found to do is to do a pickWalk -d down; to move to the objects shape node. then just do an ls -sl to get it. I think there are better ways, but this is what I have done in the past.
hope this helps,
Brad
JellyFire
12-22-2005, 09:41 AM
Thanks for your response.
I've sacked off trying to print back the result (only for testing purposes anyway)
and just implemented it into my code.
string $noName[] = `ls -sl -s`;
rename ($noName) circle;
that piece of script will rename the selected objects shape node to "circleShape"
which is exactly what I want, however, this won't work at all..
string $noName[] = `ls -sl -s`;
print ($noName);
nor
print $noName;
So I'm baffled, I don't understand why I can get it to work with rename, but not
with print, is it a glitch? Or am I writing wrong syntax?
thanks.
Jellyfire
Marcel
12-22-2005, 10:50 AM
It does exactly what you want: it prints the names of the nodes you have selected that are of the nodeType 'shape'. Since you probably select your objects in the viewport it means you are selecting the transform, and not the shape (and hence it doesn't print anything).
You can check it by selecting an object, going to hypergraph and click 'show input and oupt connections' Select the shape node and run your script again: now it prints the name of the shape.
This is how I go from transform to shape:
// get shape from object
string $currentShape[] = `listRelatives -s -path $currentObject`;
The $currentShape[0] will be the shape node connected to your transform.
john_homer
12-22-2005, 10:56 AM
I dont have maya here to test this.. but I'm pretty sure..
I'm assuming you are selecting transform nodes.
// print shape nodes of selected objects
string $sel[] = `ls -sl`; // get the selection(s)
for ($current in sel) // go through the selection and print the shape node(s) for each one
{
print (`listRelatives -s $current`);
}
edit: I guess we were typing at the same time ;^)
.j
CGTalk Moderation
12-22-2005, 10:56 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.