Search code examples
pythonmayacurvenurbs

How to select only Nurbs curves in scene with Python in Maya (without objects in hierarchy)


Suggest please a method to select all Nurbs curves in the Maya scene using Python. But I must select only curves without any other objects in the hierarchy before or after. For example, I have a hierarchy like this:

Group |NurbsCurve1 |Group |NurbsCurve2...

I've tried this

cmds.ls(et = "nurbsCurve", ni = True, o = True, r = True)

This code selects the whole hierarchy including "Group" But I need to select only NURBS curves without groups in the hierarchy. How can I do this with Python code? Thanks


Solution

  • figured out how to do it myself

    All_curves = cmds.ls(type='nurbsCurve', ni=True, o=True, r=True, l = True)
    curves_transforms = cmds.listRelatives(All_curves, p=True, type = "transform")
    cmds.select(curves_transforms)
    

    everything works