Yup this is how Autodesk/Alias figured out if a node was an instance
or not here is their "convertInstanceToObject" command:
global proc convertInstanceToObject (){
string $objects[] = `ls -sl`;
for ($object in $objects){
// confirm if object is an instance
string $children[] = `listRelatives -fullPath -children
$object`;
string $parents[] = `listRelatives -fullPath -allParents
$children[0]
`;
if (`size($parents)` > 1){
string $duplicatedObject[] = `duplicate $object`;
delete $object;
rename $duplicatedObject[0] $object;
} else {
error
(uiRes("m_convertInstanceToObject.kInstanceError")) ;
}
}
}
RyanT
Technical Artist
www.rtrowbridge.com/blog
NaughtyDog Inc.
On Mar 12, 4:33 pm, ryant <[email protected]> wrote:
> If shape has two parent transforms it must be an instance right?
>
> import maya.cmds as cmds
>
> sphere = cmds.polySphere()
> cmds.instance(sphere)
>
> getShape = cmds.listRelatives(sphere, shapes=True)
> parents = cmds.listRelatives(getShape[0], allParents=True)
> if len(parents) > 1:
> print getShape[0], "is an instance"
>
> RyanT
> Technical Artistwww.rtrowbridge.com/blog
> NaughtyDog Inc.
>
> On Mar 12, 4:21 pm, yury nedelin <[email protected]> wrote:
>
> > hi this is not really python specific but
>
> > what i a nice way to tell if object is an instance with mel/python?
>
> > Yury
>
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---