PDA

View Full Version : Adding a specific suffix to an object?


Lomax
01-28-2004, 04:51 PM
Hopefully some one can help me with this -
say I group an object to itself, and the group is automatically named group1. I'm trying to figure out how to rename the group by taking the object's name and adding "_Ctrl" to it. So far in my attempts, all I get are either syntax errors or "undeclared variables"
This is the current attempt at the script:

select group1;
$par = `listRelatives -c`;
$name = $par + "_Ctrl";
rename group1 $name;

macaroniKazoo
01-28-2004, 09:16 PM
thats a weird way of doing it - why don't you just make a function that makes the actual group for you, instead of just renaming the group thats already there?

but anyway, to answer your question, the problem is that you're treating a string array, as if it were a string.

select group1;
$par = `listRelatives -c`; <-- this returns a string array (look in the docs)
$name = $par + "_Ctrl";
rename group1 $name;

so try this:
select group1;
$par = `listRelatives -c`;
$name = $par[0] + "_Ctrl";
rename group1 $name;

perhaps a better way to do it would be this:

string $selObjs[] = `ls -sl`;
for( $obj in $selObjs ) group -name ( $obj + "_Ctrl" ) $obj;

Lomax
01-28-2004, 10:56 PM
Thanks for the reply!
I actually do have a function for creating the group, I just couldn't figure out how to get it to base its name off of the object. :shrug:

CGTalk Moderation
01-17-2006, 07:00 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.