Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Copy attribute from shape node to transform node ( for fbx export )

Copy attribute from shape node to transform node ( for fbx export )

Anonymous
Not applicable
1,027 Views
2 Replies
Message 1 of 3

Copy attribute from shape node to transform node ( for fbx export )

Anonymous
Not applicable

Hi - as subject says im trying to write a MEL script which goes through selection and looks for a certain custom attribute called DT_decoID. Since FBX exporter only exports transform node attributes I want to copy the DT_decoID value to a new attribute on the transform node called DecoForMax.

 

It kinda works, but in situations where two objects have the exact same name it get a

"Cannot evaluate more than one attribute" error. As Im very noob in MEL I was wondering if anyone has a good direction for me

br
Chr

CODE

{
//Lists the transform nodes of all selected objects in the scene
string $nodes[] = `ls -selection`;

for ($node in $nodes)
{
//From each transform node, obtain its shape node
string $shapes[] = `listRelatives -children $node`;

for ($shape in $shapes)
{


int $deco = `getAttr ($shape +".DTdecoID[1]")`;

if($deco != 0){
addAttr -ln "DecoForMax" -at long -dv 0 $node;
setAttr ($node +".DecoForMax") $deco;
}
}
}
}

0 Likes
Accepted solutions (1)
1,028 Views
2 Replies
Replies (2)
Message 2 of 3

olarn
Advocate
Advocate
Accepted solution
Message 3 of 3

Anonymous
Not applicable

just had to figure out I had to do it in listrelatives as well by -fullPath - thx for leading the way

0 Likes