def right(**kwargs): final = pm.nt.Transform(name = 'Right') innerCurve1 = pm.modeling.curve( point = [(-0.25, 0.0, -0.8), (-0.141, 0.0, -0.8), (-0.033, 0.0, -0.8), (0.0781, 0.0, -0.8), (0.228, 0.0, -0.786), (0.289, 0.0, -0.759), (0.375, 0.0, -0.722), (0.45, 0.0, -0.58), (0.45, 0.0, -0.483), (0.45, 0.0, -0.372), (0.389, 0.0, -0.236), (0.327, 0.0, -0.188), (0.261, 0.0, -0.133), (0.072, 0.0, -0.1), (-0.064, 0.0, -0.1), (-0.157, 0.0, -0.1), (-0.25, 0.0, -0.1)], knot = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 14], degree = 3 ) innerCurve2 = pm.modeling.curve( point = [(-0.25, 0.0, -0.1), (-0.25, 0.0, -0.8)], knot = [0, 1], degree = 1 ) innerCurve = pm.attachCurve( innerCurve1, innerCurve2, constructionHistory = False, replaceOriginal = False, keepMultipleKnots = True )[0] pm.delete(innerCurve1, innerCurve2) outerCurve1 = pm.modeling.curve( point = [(-0.85, 0.0, -1.2), (-0.359, 0.0, -1.2), (0.131, 0.0, -1.2), (0.336, 0.0, -1.2), (0.638, 0.0, -1.15), (0.764, 0.0, -1.073), (0.895, 0.0, -0.992), (1.05, 0.0, -0.742), (1.05, 0.0, -0.55), (1.05, 0.0, -0.278), (0.813, 0.0, 0.06), (0.612, 0.0, 0.16)], knot = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9], degree = 3 ) outerCurve2 = pm.modeling.curve( point = [(0.612, 0.0, 0.16), (1.45, 0.0, 1.2), (0.808, 0.0, 1.2), (0.111, 0.0, 0.3), (-0.25, 0.0, 0.3), (-0.25, 0.0, 1.2), (-0.85, 0.0, 1.2), (-0.85, 0.0, -1.2)], knot = [0, 1, 2, 3, 4, 5, 6, 7], degree = 1 ) outerCurve = pm.attachCurve( outerCurve1, outerCurve2, constructionHistory = False, replaceOriginal = False, keepMultipleKnots = True )[0] pm.delete(outerCurve1, outerCurve2) innerShape = innerCurve.getShape() pm.parent(innerShape, final, shape = True, relative = True) innerShape.rename('{0}InnerShape'.format(final.nodeName())) outerShape = outerCurve.getShape() pm.parent(outerShape, final, shape = True, relative = True) outerShape.rename('{0}OuterShape'.format(final.nodeName())) pm.delete(innerCurve, outerCurve) if 'radius' in kwargs: final.setScale((kwargs['radius'], kwargs['radius'], kwargs['radius'])) pm.makeIdentity(final, apply = True) return final
def duplicateAttachEdges(pEdges): """ Duplicates Curves from Edges and attach returns single curve """ dupSurfCurves = [] for aEdge in pEdges: x = pm.duplicateCurve(aEdge, ch=1, rn=0, l=0) dupSurfCurves.append(x[0]) pm.attachCurve(dupSurfCurves, ch=0, rpo=1, kmk=0, m=1, bb=0, bki=0, p=0.5) pm.select(dupSurfCurves[0]) pm.runtime.DeleteHistory() pm.language.mel.eval("CenterPivot;") pm.delete(dupSurfCurves[1::]) return pm.PyNode(dupSurfCurves[0])
def trapeziumCtrlShape(name, normalDirection=[0, 0, 0], scale=1): pm.mel.eval('softSelect -sse off;') bottomSquare = pm.nurbsSquare(c=[0, 0, 0], nr=[0, 1, 0], d=1, ch=False) topSquare = pm.nurbsSquare(c=[0, 1, 0], nr=[0, 1, 0], d=1, ch=False) leftSquare = pm.nurbsSquare(c=[-0.5, 0.5, 0], nr=[1, 0, 0], d=1, ch=False) rightSquare = pm.nurbsSquare(c=[0.5, 0.5, 0], nr=[1, 0, 0], d=1, ch=False) squareList = [bottomSquare, topSquare, leftSquare, rightSquare] for square in squareList: segmentList = pm.listRelatives(square, ad=1, type='transform') pm.attachCurve(segmentList[0], segmentList[1], ch=False, rpo=True, kmk=False, m=0, bb=0, bki=False, p=0.1) pm.attachCurve(segmentList[2], segmentList[3], ch=False, rpo=True, kmk=False, m=0, bb=0, bki=False, p=0.1) pm.attachCurve(segmentList[0], segmentList[2], ch=False, rpo=True, kmk=False, m=0, bb=0, bki=False, p=0.1) pm.delete(segmentList[1:]) cubePartsShape = [pm.listRelatives(square, ad=1, type='transform')[0].getShape() for square in squareList] for shape in cubePartsShape: pm.parent(shape, cubePartsShape[0].getParent(), r=1, s=1) # scale upper Box ctrl = pm.listRelatives(bottomSquare, ad=1, type='transform')[0] pm.parent(ctrl, w=True) pm.delete(squareList) ctrlShapesList = ctrl.getShapes() for shape in ctrlShapesList: pm.rebuildCurve(shape, ch=False, rpo=True, rt=1, end=1, kr=0, kcp=False, kep=True, kt=False, s=0, d=1, tol=0.01) vertSelection = pm.select(ctrlShapesList[3].cv[0:1], ctrlShapesList[1].cv[0:3], ctrlShapesList[2].cv[0:1]) pm.scale(vertSelection, [0.5, 0.5, 0.5], r=True) allVertSelection = pm.select([shape.cv[:] for shape in ctrlShapesList]) pm.scale(allVertSelection, [4, 1, 1], r=True) pm.select(cl=True) if normalDirection[0] == 1: pm.rotate(ctrl, [90, 0, 0]) elif normalDirection[0] == -1: pm.rotate(ctrl, [-90, 0, 0]) if normalDirection[1] == 1: pm.rotate(ctrl, [0, 90, 0]) elif normalDirection[1] == -1: pm.rotate(ctrl, [0, -90, 0]) if normalDirection[2] == 1: pm.rotate(ctrl, [0, 0, 90]) elif normalDirection[2] == -1: pm.rotate(ctrl, [0, 0, -90]) pm.rename(ctrl, name) ctrl.scale.set(scale, scale, scale) common.freezeTranform(ctrl) return ctrl