PDA

View Full Version : import into existing heirarchy?


Soulcialism
08-30-2006, 12:51 AM
hello,
so i've got a group heirarchy with meshes and bones and stuff already built out, and my plan is to have a mel script that imports a couple files (which follow the same heirarchy) and would just have the imported file kind of automatically 'sorted' into the correct group that i need it to be in. my problem is that even when i try to import my scene without adding a namespace, it still seems to add some sort of namespace (generally the file name, because of conflicting group names?). is there a way to force the file -import command to brute force import and put the objects under the groups i need them to be under?

thanks a lot!

VettoratoNode
08-30-2006, 07:25 PM
well, an alternative is putting the flag. returnNewNodes (for instance, string $newAddedNodes[] = `file -import -returnNewNodes $file`), this will return the names and fullPaths of all of the nodes imported.

VettoratoNode
08-30-2006, 07:33 PM
well, an alternative is putting the flag. returnNewNodes (for instance, string $newAddedNodes[] = `file -import -returnNewNodes $file`), this will return the names and fullPaths of all of the nodes imported.

Soulcialism
08-30-2006, 09:55 PM
yeah after consulting around, i don't think it's possible to force it into a currently existing heirarchy, so a workaround would be just to reparent the geo as a seperate part of the script i think.

thanks!

dbsmith
09-05-2006, 12:12 AM
Mind you, you could always write your own MEL script that essentially manually places each DAG object correctly in the hierarchy based on searching for its corresponding names.

//Pseudocode - you'll have to tidy it up to make it work... A lot of this borrowed from a script in David Gould's book, available on his website. I guess since you can't have the same name twice in Maya, you'll need to work around this, perhaps by giving your imported hierarchy a prefix and stripping it when you come to compare them.


//Select rootNode of old hierarchy
string $rootNode = `ls -sl`;

//Select rootNode of hierarchy to insert into
string $newRootNode = `ls -sl`;

string $childNodes[] = `listRelatives -fullPath -allDescendents $rootNode`;
string $rn[] = { $rootNode };
string $nodes[] = stringArrayCatenate( $rn, $childNodes );

string $newChildNodes[] = `listRelatives -fullPath -allDescendents $newRootNode`;
string $rn2[] = { $newRootNode };
string $newNodes[] = stringArrayCatenate( $rn2, $newChildNodes );

for ($node in $nodes){
for($newNode in $newNodes){
if($node == $newNode){ //Compare names
//Get $newNode's parent transform
$tempParent = ...;
//Place node into hierarchy
parent $node $tempParent;
//May need to use inheritTransform -off $node to stop it from moving elsewhere
inheritTransform -off $node;
//break from inner loop
break; //???
}
}
}

Dunno, might work.

CGTalk Moderation
09-05-2006, 12:12 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.