Yup, an instance is simply a DAG object with more than one parent.

Note, however, that depending on why you want to find if something is
instanced, you may need to know if ANY of it's parents are instanced -
ie, if you have this hierarchy:

parent1      parent2
   |__________|
            |
         foo
            |
          bar

...and check if bar is instanced by checking the number of it's
parents, you will return that it isn't instanced - even though it
shows up in the scene twice.  Of course, this may be the behavior you
want / need...

If not, you can instead just loop through it's parents, seeing if ANY
of them have multiple parents... OR, you can just use ls, with the
'allPaths" flag set.

- Paul


On Thu, Mar 12, 2009 at 5:21 PM, ryant <[email protected]> wrote:
>
> Sorry I found out if you select the node that you instanced from that
> prune weights works but if you select the node you did not instance
> from it does not. Wierd. Maya does not always account for this kind of
> stuff. You can get around this though by writing your own command:
>
> getShape = cmds.listRelatives("pSphere1", shapes=True)
> parents = cmds.listRelatives(getShape[0], allParents=True)
> for p in parents:
>        skin = mel.eval("findRelatedSkinCluster(\"" + p + "\");")
>        if cmds.objExists(skin):
>                print p, "is the transform that is skinned"
>
>
> On Mar 12, 5:06 pm, ryant <[email protected]> wrote:
>> Works for me. The skin is applied to the shape and there is only one
>> shape node parented to two transforms. I pruned weights and that
>> worked too. Got an example file you want to send me? I'm under your
>> same NDA ;o)
>>
>> On Mar 12, 4:52 pm, yury nedelin <[email protected]> wrote:
>>
>> > right that's all good but here is were i am confused,
>>
>> > so you have
>> > getShape[0] and 2 parents, let say sphere1 and sphere2 .
>>
>> > Skin sphere1 to a joint now your getShape[0] skinned.
>>
>> > Try pruning weights with Maya tool in Edit Smooth Skin on both sphere1 and
>> > sphere2, and shapes.
>>
>> > How can I tell which one is actually skinned and which is not? Since it's
>> > the same shape and its skinned then is should not matter but it does.
>>
>> > Yury
>>
>> > On Thu, Mar 12, 2009 at 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 Artist
>> > >www.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
-~----------~----~----~----~------~----~------~--~---

Reply via email to