zbw_curveTools.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:zTools 作者: zethwillie 项目源码 文件源码
def create_line(uniform = True, *args):
    """ 
    gets info from win to create nurbs curve along an axis
    Args:
         uniform (bool): whether the parameterization should be uniform (even), which makes the points not even
    """
    axis = cmds.radioButtonGrp(widgets["lineAxisRBG"], q=True, sl=True)
    length = cmds.floatFieldGrp(widgets["lineLenFFG"], q=True, v1=True)
    density = cmds.floatFieldGrp(widgets["lineDenFFG"], q=True, v1=True)

    numCvs = length * density
    if numCvs < 3.0: # curve needs 3 cvs (for 3 dg curve)
        numCvs = 3.0

    cvDist = length/numCvs

    # make a list of pt dist along some axis
    axisList = []
    for x in range(0,int(numCvs)+1):
        axisList.append(x)

    pts = []

    if axis == 1:
        for y in range(0, int(numCvs)+1):
            pt = [axisList[y]*cvDist, 0, 0]
            pts.append(pt)

    if axis == 2:
        for y in range(0, int(numCvs)+1):
            pt = [0, axisList[y]*cvDist, 0]
            pts.append(pt)

    if axis == 3:
        for y in range(0, int(numCvs)+1):
            pt = [0, 0, axisList[y]*cvDist]
            pts.append(pt)          

    line = cmds.curve(name = "line_01", d=3, p=pts)
    shp = cmds.listRelatives(line, s=True)[0]
    cmds.rename(shp, "{0}Shape".format(line))
    if uniform:
        line = cmds.rebuildCurve(line, rebuildType = 0, spans = 0, keepRange = 0, replaceOriginal=True, end=1, keepControlPoints=0)[0]

    cmds.select(line, r=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号