renaming something with api


#1

Hello, simple one but im a bit slow with the api.

I have created a curve and now i just want to name it. How is this done with api?

import maya.OpenMaya as om 

positions=[(1,2,3),(0,2,3),(2,3,4),(5,2,4)] 

curveFn = om.MFnNurbsCurve() 
arr = om.MPointArray() 

for pos in positions: 
    arr.append(*pos) 

obj = curveFn.createWithEditPoints( 
                                  arr, 
                                  3, 
                                  om.MFnNurbsCurve.kOpen, 
                                  False, 
                                  False, 
                                  True 
                          ) 

thanks,
Sam


#2

Searching the API doco for rename would have helped you :slight_smile:


import maya.api.OpenMaya as OM2

dagMod = OM2.MDagModifier()
currNode = #YourNode MObject here
dagMod.renameNode(currNode, "newname")
dagMod.doIt()

If it’s a DG node with no DAG corresponding node then you’ll want the DG modifier instead of the DAG modifier

OM1 should work the same of OM2


#3

thanks a lot The Jaco,

Sam