this will get all the shape nodes of the type mesh (is that the type from
modo you're bringing in?) or is it subD? anyway... you can change that part
but this should do the trick.

import pymel.core as pm
shapes = pm.ls(type="mesh")
for shape in shapes:
    parTrans = shape.getParent()
    if parTrans.nodeName() == shape.nodeName():
        pm.rename(shape,"%sShape" %shape)


On Mon, May 13, 2013 at 1:45 AM, CharlieWales <[email protected]>wrote:

> Use the 'f' (full path) flag when querying the shape node with the
> listRelatives command. It will spit back a unique node name with its full
> DAG path, which you can use in the rename command.
> El 13/05/2013 02:43, "Aleks Jones" <[email protected]> escribió:
>
> Hi. I have a situation where I have a large number of objects coming from
>> modo after being modelled. Alembic is the best way to transfer everything
>> by far, however the shape node and the transform node come in with the same
>> name. This causes problems in other scripts. Ive tried to use this to
>> rename the shape node, but because the transform has the same name, it wont
>> work. Is there a quick fix for this?
>>
>>
>> #RENAME THE SHAPE NODE TO BE UNIQUE
>> for i in cmds.ls(sl=1):
>>         cmds.select(cl=1)
>>         cmds.select(i)
>>         get_shape = cmds.listRelatives(i, shapes=1)[0]
>>
>>         get_shape_fixed = get_shape + '_shape'
>>
>>         cmds.rename(get_shape, get_shape_fixed)
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to