Python Node Type Problem

Python Node Type Problem

Anonymous
Not applicable
776 Views
4 Replies
Message 1 of 5

Python Node Type Problem

Anonymous
Not applicable
Hey,
Recently i started learning Python but today I came across a problem which seems weird to me. I'm trying to work with all the materials in my scene. So to get them all I'd do:
import maya.cmds as mc
mc.ls(type="mat")


But it always errors out, saying mat is an unknown Object Type. Maya's Python documentation though says that the Type of the materials is "mat". Even more strange: if i try the same thing in mel (ls -mat), it works, showing me the materials in my scene.
Using Maya 2011.

I would be very thankfull for help!
0 Likes
777 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I think mat only works in MEL. In Python, you need the proper type

cmds.ls(type='phong')

but, since phong is derived form lambert, you can do

print cmds.ls(type='lambert')


to get ONLY lambert, you would use:
print cmds.ls(exactType='lambert')
0 Likes
Message 3 of 5

Anonymous
Not applicable
thanks for your help! sad to hear that this command doesnt work though... is there any other way to list all the materials? or has it been fixed in 2012?

oh, and another question (as i dont wanna make a new thread for this): is there any way I could get the input or output connection of a node? so that i can check if theres for example a file node connected to the color of my material?

thanks once again in advance
0 Likes
Message 4 of 5

Anonymous
Not applicable
thanks for your help! sad to hear that this command doesnt work though... is there any other way to list all the materials? or has it been fixed in 2012?


cmds.ls(mat=True)


oh, and another question (as i dont wanna make a new thread for this):


and yet that would be the right thing to do


is there any way I could get the input or output connection of a node? so that i can check if theres for example a file node connected to the color of my material?


cmds.nodeType(cmds.listConnections('phong1.color'))
0 Likes
Message 5 of 5

Anonymous
Not applicable
thanks so much, you really helped me out!
0 Likes