[英]python maya: Align group pivot to supplied position
我這里是一個腳本,在其中我創建了一個圈子束並將其放入一組。 然后,我將組的軸心居中到邊界框。 最后,我想通過首先收集定位器的位置來將組的位置與空間中的位置對齊。 我怎樣才能解決這個問題? 目前,它似乎無法正確對齊。 錯誤發生在代碼的最后一行。 謝謝高級人員。
import maya.cmds as cmds
import random
cmds.file(new=True, f=True)
a = cmds.spaceLocator(n='pipeCtrl_00')
x = random.uniform(-10,10)
z = random.uniform(-10,10)
cmds.xform(a, t=(x,0,z) )
#select all the locators you want to make curves on
locList = cmds.ls(type='locator')
nodes = maya.cmds.listRelatives(locList, type='transform', parent=True)
sorted(nodes)
points = []
#get position points
for n in nodes:
pos = cmds.xform(n, q = True, ws = True, t = True)
points.append(pos)
# create 2D grid of circles
numRows = 4
numColumns = 4
#create empty group for nodes
nodeGroup = cmds.group(em=True, name='Pipe_group_00')
for r in range(0,numRows):
for c in range(0,numColumns):
# Create circle shape and transform it
node = cmds.circle(ch=True, o=True, nr=(0, 0, 1), c=(0, 0, 0), r=.5)
cmds.xform(node, t=(r*(.5*2), c*(.5*2), 0) )
# Parent node under the group node
cmds.parent(node[0], nodeGroup, relative=False)
# center pivot of group node
cmds.xform(nodeGroup, cp=True)
# align group to path
# ------------------------------------------------------------------
print points[0]
cmds.xform(nodeGroup, ws=True, t=points[0] )
我想你要
cmds.xform(nodeGroup, cp=True, p=True)
檢查文檔中的-p標志
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.