Thursday, July 18, 2013

For Maya TD's - IsShape

How can we know about a node whether it is a shape or not?
The problem is that in maya shape as a node type does not exist.
So I wrote this python script:

 def IsShape(Selection):   
     shapeNodeList = []   
     for node in Selection:   
         if cmds.nodeType(cmds.listRelatives(node, p = 1, path = 1)) == "transform" and cmds.nodeType(node) != "transform":   
             shapeNodeList.append(node)   
     return shapeNodeList  

The idea behind this if a node is not transform but the parent node is, that particular node has to be a shape. I could not produce an error yet (of course there has to be a selection).
Is it correct or somebody has a better idea?

No comments:

Post a Comment