Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Python / Python Node Type Problem
  RSS 2.0 ATOM  

Python Node Type Problem
Rate this thread
 
55466
 
Permlink of this thread  
avatar
  • Jimster
  • Posted: 06 May 2011 11:02 AM
  • Total Posts: 6
  • Joined: 06 March 2009 06:02 PM

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!



Replies: 0
avatar
  • THNKR
  • Posted: 06 May 2011 02:30 PM

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’)



Replies: 0
avatar
  • Jimster
  • Posted: 06 May 2011 09:42 PM

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



Replies: 0
avatar
  • THNKR
  • Posted: 07 May 2011 02:49 AM

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’))



Replies: 0
avatar
  • Jimster
  • Posted: 07 May 2011 03:36 AM

thanks so much, you really helped me out!



Replies: 0