Problem: I have a bunch of OBJs to process in maya.
the OBJ meshes are misnamed, so I need to automate the renaming, among other stuff.
after I import the obj, I want to select its transform.
cmds.ls(typ=‘transform’) will grab the cameras as well as the mesh, so that won’t work.
The only way I can think of to isolate the mesh is cmds.ls(typ=‘mesh’)
but this grabs the shape node, not the transform.
I have indirect approach that replaces ‘Shape’ in the mesh node string to generate the transform node name…but this feels hacky and possibly unreliable.
import maya.cmds as cmds
itemShape=(cmds.ls(typ='mesh')[0])
cmds.select(itemShape.replace('Shape',''))#remove 'Shape' to yield transform name
selection=cmds.ls(sl=True)
itemMesh=selection[0]
print (itemMesh)
print(cmds.nodeType(itemMesh))
a second also indirect approach is to select only visible transforms with
cmds.ls(v=True ,typ=‘transform’) but it’s still…indirect.
Is there away to explicitly list the transforms of shapes?