python maya:循环遍历曲线顶点和圆角

时间:2014-04-04 22:13:20

标签: python maya

我想要做的就是使用随机点创建样条曲线,然后通过样条曲线将填充符添加到可用的曲线顶点。

在Maya中做一个基本的圆角似乎相当沉重,所以我想通过代码循环选择样条顶点来实现它。

import maya.cmds as cmds
path = cmds.curve(d=1, p=[(0, 0, 0), (0, 0, 6), (5, 0, 6), (9, 0, 9)] )

我知道您可以通过执行以下操作来根据半径填充角落。 1.创建一条曲线 2.选择2'曲线点'每个人都在不同的部分 3.使用'修剪'运行曲线圆角。和#39;加入'使用所需的半径大小。

我想知道的是,是否有可能应用此方法并对样条曲线的所有片段进行填充。

enter image description here

更新: 这就是我到目前为止所做的事情,它并不想多次填充为什么会这样做?

#maya has a shape node for every transform object
#cmds.ls(sl=True, t="transform")

import maya.cmds as cmds
import random

a = cmds.spaceLocator(n='pipeCtrl_00')
b = cmds.spaceLocator(n='pipeCtrl_00')
c = cmds.spaceLocator(n='pipeCtrl_00')
d = cmds.spaceLocator(n='pipeCtrl_00')
cmds.xform(a, t=(0,0,0) )
cmds.xform(b, t=(0,0,-6) )
cmds.xform(c, t=(6,0,-6) )
cmds.xform(d, t=(6,0,-12) )


#select all the locators you want to make curves on
items = cmds.ls(type='locator') #cmds.ls(sl = True)
locList = maya.cmds.listRelatives(items, type='transform', parent=True)
sorted(locList)
crvList = []

#run locators through a loop and make a curve segment from 1 to another.
for index in range(0,len(locList)-1):
 crvName = "myCurve"+str(index) 
 aLocPos = cmds.xform(locList[index], q = True, t = True)
 bLocPos = cmds.xform(locList[index+1], q = True, t = True)
 cmds.curve(d=1,n=crvName, p=[(aLocPos[0], aLocPos[1], aLocPos[2]), (bLocPos[0], bLocPos[1], bLocPos[2])] )
cmds.select("myCurve*")
crvList=cmds.ls(sl=True)

#Curve fillet each segment section with random radius.
#for index in range(0,len(crvList)-1):
 #aCrv = crvList[index] 
 #bCrv = crvList[index+1]
 #randRadius = random.randrange(1, 3)
 #cmds.filletCurve(aCrv, bCrv, r=randRadius)
 #aCrv=cmds.ls(sl=True)

#Curve fillet each segment section with random radius
for idx in range(0,len(crvList)-1):
 curveA = crvList[idx]
 curveB = crvList[idx+1]
 randRadius = random.uniform(0.5, 1.5)

 m = cmds.filletCurve(curveA, curveB, r=1.5 , cir=True, t=True, jn=True)

0 个答案:

没有答案