我正在根據用戶選擇創建一個串列,并希望為串列中的每個選定專案(物件、頂點等)在該專案的世界位置創建一個定位器:
import maya.cmds as mc
selection = mc.ls(sl=True)
for each in selection:
newLoc = mc.spaceLocator()
mySelPosition = mc.xform(selection, q=True, ws=True, t=True)
mc.move(mySelPosition[0], mySelPosition[1], mySelPosition[2], newLoc)
這在選擇物件(比如兩個球體)時不起作用,它只是在原點創建一個定位器。
選擇多個頂點時,它會創建與所選串列項一樣多的定位器,但它們都是在串列中的第一項創建的。
uj5u.com熱心網友回復:
不確定我是否遵循,但我認為您的問題在第 6 行,
mySelPosition = mc.xform(selection, q=True, ws=True, t=True) # your line
mySelPosition = mc.xform(each, q=True, ws=True, t=True) # correct line
嘗試這個:
import maya.cmds as mc
selection = mc.ls(sl=True)
for each in selection:
newLoc = mc.spaceLocator()
mySelPosition = mc.xform(each, q=True, ws=True, t=True)
mc.move(mySelPosition[0], mySelPosition[1], mySelPosition[2], newLoc)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/504650.html
上一篇:使用Ansible構建專有名稱
