Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

select all object that are not assigned to specefic material

Amit_Karny_עמית_קרני
Advocate
Advocate

select all object that are not assigned to specefic material

Amit_Karny_עמית_קרני
Advocate
Advocate

Hi there!

 

I'm looking to select all object that are assigned to Aitoon, but the problem is that I do have several Aitoon Materials (differenet attributes values). Otherwise, I need to exclude select all object that are not assign to Aitoon and than making any deselection. like that 

hyperShade -o "lambert1"

 

Dont wanna make it manually command  for each Material.

 

P.S

 

Do I need to use Filter?  

0 Likes
Reply
198 Views
3 Replies
Replies (3)

Kahylan
Advisor
Advisor

Hi!

 

You can get all your aiToon shaders by listing all objects of type "aiToon"

 

Getting the connected objects is a case of following the connections afterwards.

 

This is how you do it in Python:

import maya.cmds as mc

aiT = mc.ls(type = "aiToon")

objects = []
for t in aiT:
    sg = mc.listConnections("{0}.outColor".format(t), s = True)
    for g in sg:
        empty = False
        i = 0
        while empty == False:
            objs = mc.listConnections('{0}.dagSetMembers[{1}]'.format(g, i), d = True)
            if objs == None:
                empty = True
            else:
                for o in objs:
                    objects.append(o)
                    i = i+1
print (objects)    
        

 

I sadly don't have a Mel solution at hand right now, but you should be able to figure out how to rewrite this in Mel.

 

I hope it helps!

0 Likes

Amit_Karny_עמית_קרני
Advocate
Advocate
I will check this out thanks a lot!

0 Likes

Amit_Karny_עמית_קרני
Advocate
Advocate

it print me back 

# Error: ValueError: file <maya console> line 12: No object matches name:.....
0 Likes