I am just getting started out trying to understand Python (and programming in general). I'm trying to make a simple script that renames all my selected objects. Obviously this should be super simple, but when I run what I have so far, it only renames one object regardless of what is selected.
import maya.cmds as cmds
def renameFun ():
mySel = cmds.ls (selection = True)
newName = "Test_Name"
for i in range (len(mySel)):
cmds.rename(newName + "_%d" % i)
I am calling the function when I run it in Maya. Any help would be very appreciated!
Aren
import maya.cmds as cmdsdef renameFun ():
mySel = cmds.ls(selection=True)newName = "Test_Name"for i, orig in enumerate(mySel):cmds.rename(orig, "%s_%d" % (newName, i))
i = 0for orig in mySel:...i += 1
--To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/52c9e4c4.08eac20a.6b33.ffffbebf%40mx.google.com.
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.