Select instances

1,255 views
Skip to first unread message

Steve Davy

unread,
Jul 10, 2014, 3:39:11 PM7/10/14
to Maya Group
Can't believe I don't know how to do this and/or it's not immediately obvious in Maya.

How can I pick an instanced object OR an object that has instances, then easily select ALL transforms associated with this instance?

I find instances in Maya to be a horror show and right now have a file with multiple instanced objects but no easy way to select them as groups for batch processing.

sid

unread,
Jul 10, 2014, 4:59:50 PM7/10/14
to maya...@googlegroups.com
Using....... python *RUNS AND HIDES*

Yeah, I know, the answer in Maya is always scripting. *shrug*.

If you select one of your instanced shape nodes and run the following, you should get a list of transforms returned.

import pymel.core as pm

sel = pm.ls(sl=True)[0]
fullpathtoshape = sel.getInstances()

for shape in fullpathtoshape:
    print shape.getParent()



Let me know if you need any mods to the code.

Sid


--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yi Liang Siew

unread,
Jul 10, 2014, 5:09:10 PM7/10/14
to maya...@googlegroups.com

Hi Steve:

When you instance an object in Maya, you are basically creating a new transform, and associating the instance's shape node with that transform (The lack of connections from the shapeNode to the transform node is a little annoying).

Thus you can do the following:

import maya.cmds as mc

list=[]

for s in mc.ls(typ='transform'):
    shape = mc.listRelatives(s, ad=True, s=True)
   
    if shape is not None:
   
        if shape[0] == 'pCubeShape2':
            list.append(s)
           
mc.select(list, r=True)

There's probably an easier way to do it with a specific method for this, but I'm not aware of one. (Anyone...?)

Yi Liang Siew

unread,
Jul 10, 2014, 5:11:47 PM7/10/14
to maya...@googlegroups.com
Or that, haha. :P

Steve Davy

unread,
Jul 10, 2014, 6:50:08 PM7/10/14
to Maya Group
Yes, aware what instancing is, I'm just not much of a scripter although I know this is indeed usually the answer to anything batch oriented in Maya. I find it mind boggling that this actually requires it, however.


Thanks for the code.... we'll try this if the task that required it now comes back from the dead again.... ;)


Date: Thu, 10 Jul 2014 14:07:52 -0700
From: son...@gmail.com
To: maya...@googlegroups.com
Subject: Re: [maya_he3d] Select instances

matt estela

unread,
Jul 10, 2014, 7:20:10 PM7/10/14
to maya...@googlegroups.com
You probably know this already, but pick-walk can sometimes be useful. Click a transform in the outliner, down will select the shape (and hence every instance), up will go back to the single transform.

Steve Davy

unread,
Jul 10, 2014, 7:23:41 PM7/10/14
to Maya Group
Yep. Was looking for a way to select all the transforms based on the selection of any instance.

Retarded that Maya doesn't have a built-in tool for this.


From: ma...@tokeru.com
Date: Fri, 11 Jul 2014 09:19:48 +1000

Subject: Re: [maya_he3d] Select instances
Reply all
Reply to author
Forward
0 new messages