0
我需要python中的一些幫助來獲取Maya中的聯合列表。我是一個新手,所以仍然在學習。以下是我想要做的: - 對於場景中存在的每個關節或關節,我想爲每個關節創建一個NURBS圓,並將其位置與場景中的關節相匹配。這是我到目前爲止:如何使用Maya Python lib爲場景中的每個關節創建NURBS圓?
selected = cmds.ls(sl=True) #First joint selected)
joint_translate = cmds.xform(selected[1], query=True, translation=True, worldSpace=True) #first joint translation value.
joint_rotate = cmds.xform(selected[1], query=True, rotation=True, worldSpace=True) #first joint rotation value.
cmds.xform(selected[0], translation=joint_translate, worldSpace=True) #matching whatever is selected to the first joint.
cmds.xform(selected[0], rotation=joint_rotate, worldSpace=True)
但我想存儲所有的翻譯和旋轉值而不選擇它們。如何存儲每個關節轉換值以及如何存儲每個關節的名稱。然後創建圓並將其與每個關節進行匹配。我知道我必須爲此使用for循環。我這樣做:
joints = cmds.ls(type='joint')
selected = cmds.ls(sl=True)
joint_translate = cmds.xform(selected[0], query=True, translation=True, worldSpace=True)
joint_rotate = cmds.xform(selected[0], query=True, rotation=True, worldSpace=True)
cmds.circle(nr=(1,0,0), c=(0, 0, 0), r=1.5, n='Circle1')
cmds.xform('Circle1', translation=joint_translate, worldSpace=True)
cmds.xform('Circle1', rotation=joint_rotate, worldSpace=True)
,但它只是適用於首次聯合(這我是知道的),但我用的確切名稱來匹配它(這就是爲什麼它的工作)。我想這樣做,而不使用圈子的名稱。
整點是爲場景中的每個關節創建NURBS圓。關節可能是3或5或20
任何幫助是極大的讚賞:)
非常感謝你的這份工作。只是一個簡單的問題,怎麼可以告訴瑪雅只適用於某些關節的範圍。如果有接頭1-10,我希望此代碼僅適用於接頭3-8。如何存儲和應用? –