英文:
How to select only Nurbs curves in scene with Python in Maya (without objects in hierarchy)
问题
请提供一种方法,使用Python在Maya场景中选择所有的Nurbs曲线。但我必须仅选择层次结构中之前或之后没有任何其他对象的曲线。
例如,我有这样的层次结构:
组
|NurbsCurve1
|组
|NurbsCurve2...
我尝试过这个:
cmds.ls(et="nurbsCurve", ni=True, o=True, r=True)
这段代码选择了整个层次结构,包括“组”。
但我需要仅选择层次结构中没有组的NURBS曲线。
如何使用Python代码做到这一点?
谢谢
英文:
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
答案1
得分: 0
已找到如何自行操作。
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)
一切正常。
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论