|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
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!
|
|
|
|
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’)
[u’lambert1’, u’phong1’]
to get ONLY lambert, you would use:
print cmds.ls(exactType=’lambert’)
|
|
|
|
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
|
|
|
Jimster 07 May 2011 04:42 AM
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’))
|
|
|
|
thanks so much, you really helped me out!
|
|
|
|
|
|