PDA

View Full Version : Problem in locking attributes


Grayth
10-21-2005, 02:52 PM
I can't for the life of me figure out what I'm doing wrong.
I've looked at the example flags and reference and it looks fine
but I keep getting no attribute specified and I'm thinking...yes I'm locking translate X...

here's the sample code

string $name = "bob";
camera;
rename $name; //I've renamed it this way as I can't see how in the camera create command where I can specify a name

setAttr -lock true $name.tx;

The other problem I'm having is in creating new group nodes..
I can't find the right command to select the top most group node.
example when I create a 2node Camera..it also creates a camera1_group node.
I want to be able to create new group nodes above this node.

I know I can simply select this...but if the script is creating multiple cameras, this group node name will change.

Thanks for the help on these 2 problems

Troy

mhovland
10-21-2005, 04:51 PM
Try this:

setAttr -lock true ($name+".tx");

You have the name stored in a string variable, and you need to put the two pieces of string data together. This is called string catenation.

What is going on is you are saying to take what is in the variable $name (bob) and add (.tx) to it, giving you "bob.tx".

For your second issue, capture the results from the camera; command into a varible. The camera command returns a string[] that contains the camera name, and the camera shape node.

Add this into your code:

$cam[] = `camera`;
print $cam;

This will show you the names after they are created. You then rename the camera to "bob". This will change the name of the shape node as well to "bobShape". If you want to create a group....

select -r "bob";
group;

Or

group "bob";

Does that help?

Grayth
10-21-2005, 05:32 PM
Thanks, thata's awesome...


the second solution doesn't work as I tried that. The problem is I can change the name of the camera and the shapenode ok...it's the camera1_group node above it..

it looks lihe this
camera1_group
camera "bob"
locator aim

When I add a group it adds the group above the camera "bob" and not above camera1_group where I want it..I can simply select -r camera1_group..this works till I create another camera from the script..then I have a conflict.

Thanks,
Troy

Keilun
10-21-2005, 07:01 PM
You have two options to get the parent:

1) `select camera1`
2) `pickWalk -d up`

This will select the parent to camera1. Of course in this case you still need to know how many times you want to traverse up the DAG.

-OR-

You will need to make use of the listRelatives command to determine the parents to the given transform. If you have camera1 selected, for instance, then you would need to call `listRelatives -p camera1` or alternatively `listRelatives -ap camera1` depending on the DAG layout. This will return the name of the parent transform and you can check the name to see if that's the one you're looking for or not. I can't really elaborate much further without more info on what the scenario is.

HTH.

CGTalk Moderation
10-21-2005, 07:01 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.