import maya.cmds as mc
import re
SUFFIXES = { 'mesh' : 'geo', 'joint' : 'jnt', 'follicle' : 'fol', 'nurbsCurve' : 'crv',}
GROUP = 'grp'
def renameObject(object):
for obj in object: sN = obj.split('|')[-1]
lR = mc.listRelatives(sN, s=1)
if lR == None: objType = mc.objectType(obj) else: objType = mc.objectType(lR)
suffix = SUFFIXES.get(objType, GROUP)
regex = r'_.*'
if not suffix: continue
if sN.endswith('_' + suffix): continue
if re.match(regex, sN): continue
newName = "%s_%s" % (sN, suffix)
mc.rename(sN, newName)
index = object.index(obj)
object[index] = obj.replace(sN, newName)
return object
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1a3567b0-e603-4c3c-8499-ca04a7bafe35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On regex, I would like to create that if the object with '_ + without string on dictionary' then it won't do repeat again. So the result still keep on '_+ without string on dictionary' not '_+ without value on dictionary + _ + value dictionary'.
Let say I have 'mesh_ply' then i wanna keep on 'mesh_ply'. I don't wanna it comes to 'mesh_ply_geo'
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9df1940a-9331-4434-a50c-6e683e167e11%40googlegroups.com.
Hi,My bad, It turns out very simple! :D I was thinking to far and misleading about the regex terms then coming up to logical fallacy by ends. So thank you Justin, I learnt a lot since last night and work perfectly now!
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/732937b0-8ef3-4122-9947-8ba3128c0e0c%40googlegroups.com.