Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # First lets import our Maya command library
- from maya import cmds
- # Then we import our file. In this case I'm using a hardcoded value
- # But notice the returnNewNodes parameter that tells it to give us back any imported nodes
- # This may contain nodes we don't want
- # So we'll need to shorten it down
- nodes = cmds.file('C:/Users/dhruv/Documents/maya/controllerLibrary/bigdonut.ma',
- i=True, returnNewNodes=True)
- # We need to find all the objects that are shapes
- # We use ls to list the nodes we got, and to make sure we only get the shapes
- shapes = cmds.ls(nodes, shapes=True, shortNames=True)
- # We'll have an empty list to get the controllers
- controllers = []
- # Then lets loop through this list
- for shape in shapes:
- # We want to ignore any cameras so we check the type
- if cmds.objectType(shape) == 'camera':
- # If it's a camera then continue on to the next item
- continue
- # Then we need to find the transform.
- # So we list its' parent to find it
- parent = cmds.listRelatives(shape, parent=True)[0]
- # Then we add the parent transform to the controllers list
- controllers.append(parent)
- # Finally lets print out the controllers to see if we got it right
- print controllers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement