PDA

View Full Version : newbie gives. anyone want to help?


ikaika1
10-10-2005, 12:53 AM
Ok, So I want to create multiple nail constraints for an array of objects, but I want the constraint to appear at the center of the object/ at the pivot point. This is what ive got:


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

for ( $node in $select )
{
select -r $node ;
string $nodename = $node ;
float $pivotpos[] = getAttr("$nodename.translate") ;
constrain -nail -p $pivotpos[1] $pivotpos[2] $pivotpos[3] ;
select -r $select ;
}

Its dieing at the call for $nodename.translate in the getAttr, but I have no clue how to do this without that particular function call. Help?

xenoid
10-10-2005, 10:08 AM
hihi...

your command
float $pivotpos[] = getAttr("$nodename.translate") ;
should actually be
float $pivotpos[] = `getAttr($nodename+".translate") `;

Don't forget the 2 red ticks symbols as they are required for all MEL commands called in this manner...

Also, $nodename is a variable and not a string by itself, thus you need the "+" to help you combine the ".translate" string to form the full command.

Hope it helps :)

ikaika1
10-10-2005, 11:35 PM
Thanks for the syntax help. Now I guess, having tested it, I need some more practical help.

One end of the nail constraint goes to the

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

for ( $node in $select )
{
select -r $node ;
float $pivotpos[] = `getAttr($node+".translate") `;
constrain -nail -p $pivotpos[1] $pivotpos[2] $pivotpos[3] $node ;
select -r $select ;
};

ikaika1
10-10-2005, 11:43 PM
Got, it:

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

for ( $node in $select )
{
select -r $node ;
float $pivotpos[] = `getAttr($node+".translate") `;
string $rnc = `constrain -nail -p $pivotpos[1] $pivotpos[2] $pivotpos[3] $node` ;
setAttr($rnc+".translateX") $pivotpos[0];
setAttr($rnc+".translateY") $pivotpos[1];
select -r $select ;
};




Ok, this is going to show up twice, but I cant edit my previous post... Ill delete it later.

Thank you for the syntax help!

Having tested this, I get one end of the nail constraint at the center of the object as expected, but the other end is very close to the origin, usually at a distance some fraction of the amount that it needs to be. So, for clarification, i want the object to pivot about its center with no length to the "tether" or "nail," but the nail is actually almost the full distance from the center of the object to the origin. Is there a way to get the constraint to create at the pivot point or do I need to move the position of the rigidnailconstraint in the script? How does one reference the rigidnailconstraint that was just created from the constrain command? Is there a book someone can recommend? :P

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

for ( $node in $select )
{
select -r $node ;
float $pivotpos[] = `getAttr($node+".translate") `;
constrain -nail -p $pivotpos[1] $pivotpos[2] $pivotpos[3] $node ;
select -r $select ;
};

CGTalk Moderation
10-10-2005, 11:43 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.