Home Technical Talk

Pymel/Maya python help

RealityFix
polycounter lvl 5
Offline / Send Message
RealityFix polycounter lvl 5
I'm having issue grabbing the all of the curves in a hierarchy and setting their rotations back to 0. I've been trying for the past hour and only recently learned about using PyMel. Any help is appreciated. I've had different variations that didn't give me an error but didn't do anything as well... so far the error with this code is "rotation" is not an attribute to x. I don't think I implemented the PyMel quite correctly.

Thanks once again for any help:
import maya.cmds as cmds
from pymel.core import *

mySelect = cmds.select(cmds.ls(dag = 1, ap = 1, sl = 1, type = "nurbsCurve"))
AddtoList = cmds.ls(sl =1)

for x in AddtoList:

       if setAttr(x.rotate) == True:
           x.rotate(0,0,0)
       else:
           pass
       
I'm also a bit of a noob when it comes to coding. So there is a mix of just python and PyMel. I only just tried PyMel a moment ago and didn't feel like deleting some older code.

Replies

  • RealityFix
    Options
    Offline / Send Message
    RealityFix polycounter lvl 5
    my friend figured it out for me cause I'm just not very good really:
    import maya.cmds as cmds from pymel import *
     
    
     objName = cmds.ls(sl=1)
     prefix = objName[0].split(':',-1)[0]
     
    
     con_shapeNode_list = cmds.ls('{}:*'.format(prefix), type = "nurbsCurve")
     
    
     con_transformNode_list = cmds.listRelatives(con_shapeNode_list, p=1, type= 'transform')
     
    
     
    
     
    
     for x in con_transformNode_list:
         cmds.xform(x, ro= (0,0,0), os = 1)
         cmds.cutKey(x, s=True)    
     
    
    
    
    I added delete keyframes in there for good measure. Maybe someone will find this mildly useful. Takes into account namespaces
Sign In or Register to comment.