Hello,
I am trying to do what should be a simple rename, but I am having a
few problems that I think are a bug, but hopefully just me not
realizing an error I am making.

I am writing a script to add a suffix to all meshes : "_geo". It goes
like this:

import maya.cmds as mc
meshs = mc.ls(l=True,type='mesh')
for mesh in meshs:
        # get parent transform
        transforms = mc.listRelatives(mesh, fullPath=True,parent=True)
        transform = transforms[0]
        print 'working on ' + transform
        # if there is no _geo at the end, put one there
        if not transform .endswith("_geo"):
                shortName = transform.split("|")
                newName = shortName[-1] + "_geo"
                print "rename %s to %s " % (transform,newName)
                mc.rename(transform,newName)

If I create a new scene, with 2 sphere meshes, it works fine.
If I group each sphere into its own group, and then name the spheres
the same, I get errors.

group1|pSphere
group2|pSsphere

When I run the script I do get

group1|pSphere_geo
group2|pSphere_geo

but I also get this error in the script editor:
working on |group1|pSphere1
rename |group1|pSphere1 to pSphere1_geo
working on |group2|pSphere1
rename |group2|pSphere1 to pSphere1_geo
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: More than one object matches name: pSphere1_geoShape //
// Error: Cannot convert data of type int[] to type int. //
// Error: More than one object matches name: pSphere1_geoShape //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Illegal operation "!" on data of type int[]. //
// Error: Illegal operation "!" on data of type int[]. //
// Error: Illegal operation "!" on data of type int[]. //
// Error: Illegal operation "!" on data of type int[]. //
// Error: Cannot convert data of type int[] to type int. //
// Error: Cannot use data of type int[] in a scalar operation. //


Anyone have any idea why? And what other method I could do to rename
the same named objects?


--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to