Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. # First lets import our Maya command library
  2. from maya import cmds
  3.  
  4. # Then we import our file. In this case I'm using a hardcoded value
  5. # But notice the returnNewNodes parameter that tells it to give us back any imported nodes
  6. # This may contain nodes we don't want
  7. # So we'll need to shorten it down
  8. nodes = cmds.file('C:/Users/dhruv/Documents/maya/controllerLibrary/bigdonut.ma',
  9. i=True, returnNewNodes=True)
  10.  
  11. # We need to find all the objects that are shapes
  12. # We use ls to list the nodes we got, and to make sure we only get the shapes
  13. shapes = cmds.ls(nodes, shapes=True, shortNames=True)
  14.  
  15. # We'll have an empty list to get the controllers
  16. controllers = []
  17.  
  18. # Then lets loop through this list
  19. for shape in shapes:
  20. # We want to ignore any cameras so we check the type
  21. if cmds.objectType(shape) == 'camera':
  22. # If it's a camera then continue on to the next item
  23. continue
  24. # Then we need to find the transform.
  25. # So we list its' parent to find it
  26. parent = cmds.listRelatives(shape, parent=True)[0]
  27.  
  28. # Then we add the parent transform to the controllers list
  29. controllers.append(parent)
  30.  
  31. # Finally lets print out the controllers to see if we got it right
  32. print controllers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement