Пример #1
0
    def diamondCurve3D(name):

        curveX = mel.eval(
            '''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 0 0.000151268 -1.035395 -p 0 0 0 
            -p 0 -0.988362 0 -p 0 0 0 -p 0 -0.000151268 1.035697 -p 0 0 0 -p 0 0.809437 0 -k 0 -k 0 
            -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')

        cmds.closeCurve(curveX, ch=1, ps=2, rpo=1, bb=0, bki=1, p=0.1)

        curveZ = mel.eval(
            '''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 1.071098 0.000156484 0 
            -p 0 0 0 -p 0 -0.988362 0 -p 0 0 0 -p -1.071411 -0.000156484 0 -p 0 0 0 -p 0 0.809437 0 
            -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')

        cmds.closeCurve(curveZ, ch=1, ps=2, rpo=1, bb=0, bki=1, p=0.1)

        curveZShape = cmds.listRelatives(curveZ, s=True)

        cmds.parent(curveZShape, curveX, r=True, s=True)

        cmds.rename(curveX, name)
        cmds.delete(curveZ)
        curveShapes = cmds.listRelatives(name, s=True)

        return curveShapes
Пример #2
0
    def create(self, crv_name, name='curve_shape', scale=1, orientation_override=None):
        """
        To Write..
        """
        # Create and rename curve
        try:
            crv = cmds.curve(d=self.CURVES[crv_name]['degree'], p=self.CURVES[crv_name]['points'])
            crv = cmds.rename(crv, name)
        except KeyError:
            crv = None
            cmds.warning("Curve '%s' does not exist..")

        if self.CURVES[crv_name]['closed']:
            cmds.closeCurve(crv, rpo=True, ps=0)

        # Determine whether to use the orientation_override or the factory's orientation
        if orientation_override is None:
            orient = self.orientation
        else:
            orient = orientation_override

        # Orient control
        if orient == 'x':
            cmds.xform(crv, ws=True, ro=(0, 0, 90))
        elif orient == 'y':
            pass
        elif orient == 'z':
            cmds.xform(crv, ws=True, ro=(90, 0, 0))
        else:
            cmds.warning("Invalid orientation: '%s'" % orient)

        cmds.xform(crv, ws=True, scale=(scale, scale, scale))
        cmds.makeIdentity(crv, apply=True)

        return crv
Пример #3
0
 def TDSquare(self, name):
     self.SquareCurve = cmds.curve(d=1,
                                   n=name,
                                   p=[(1, 0, -1), (-1, 0, -1), (-1, 0, 1),
                                      (1, 0, 1), (1, 0, -1)])
     cmds.closeCurve(self.SquareCurve, ps=1, rpo=1, bb=0.5, bki=0, p=0.1)
     return self.SquareCurve
Пример #4
0
 def diamondCurve3D(name):
 
     curveX = mel.eval('''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 0 0.000151268 -1.035395 -p 0 0 0 
         -p 0 -0.988362 0 -p 0 0 0 -p 0 -0.000151268 1.035697 -p 0 0 0 -p 0 0.809437 0 -k 0 -k 0 
         -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')
         
     cmds.closeCurve(curveX,ch  = 1,ps = 2,rpo = 1, bb = 0,bki =  1, p = 0.1)
         
         
     curveZ = mel.eval('''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 1.071098 0.000156484 0 
         -p 0 0 0 -p 0 -0.988362 0 -p 0 0 0 -p -1.071411 -0.000156484 0 -p 0 0 0 -p 0 0.809437 0 
         -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')
     
     cmds.closeCurve(curveZ,ch  = 1,ps = 2,rpo = 1, bb = 0,bki =  1, p = 0.1)
     
     curveZShape = cmds.listRelatives(curveZ,s = True)
     
     cmds.parent(curveZShape,curveX,r = True, s = True)
     
     
     cmds.rename(curveX,name)
     cmds.delete(curveZ)    
     curveShapes = cmds.listRelatives(name,s = True)
     
     return curveShapes
Пример #5
0
 def diamondCurve(name):
     
     curve = mel.eval('''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 1.071098 0.000156484 0 
         -p 0 0 0 -p 0 -0.988362 0 -p 0 0 0 -p -1.071411 -0.000156484 0 -p 0 0 0 -p 0 0.809437 0 
         -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')
     
     cmds.closeCurve(curve,ch  = 1,ps = 2,rpo = 1, bb = 0,bki =  1, p = 0.1)
     
     cmds.rename(curve,name)
     curveShapes = cmds.listRelatives(name, s = True)
     
     return curveShapes
Пример #6
0
    def diamondCurve(name):

        curve = mel.eval(
            '''curve -d 3 -p 0 0.809437 0 -p 0 0 0 -p 1.071098 0.000156484 0 
            -p 0 0 0 -p 0 -0.988362 0 -p 0 0 0 -p -1.071411 -0.000156484 0 -p 0 0 0 -p 0 0.809437 0 
            -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;''')

        cmds.closeCurve(curve, ch=1, ps=2, rpo=1, bb=0, bki=1, p=0.1)

        cmds.rename(curve, name)
        curveShapes = cmds.listRelatives(name, s=True)

        return curveShapes
Пример #7
0
    def ControlTypes (self, shape):

        if shape == "Diamond":
            self.ctrls = cmds.curve(d=1, p=[(-1, 0, -1), (-0.5, 0, 0), (-1, 0, 1), (0, 0, 0.5), (1, 0, 1),
                                            (0.5, 0, 0), (1, 0, -1), (0, 0, -0.5)], k=[0, 1, 2, 3, 4, 5, 6, 7])
            self.ctrls = cmds.closeCurve(ch=True, ps=True, rpo=True, bb=1, bki=False, p=0.1)

        elif shape == "Square":
            self.ctrls = cmds.curve(d=1, p=[(-1, 0, -1), (-1, 0, 1), (1, 0, 1), (1, 0, -1)],
                                    k=[0, 1, 2, 3])
            self.ctrls = cmds.closeCurve(ch=True, ps=True, rpo=True, bb=1, bki=False, p=0.1)

        elif shape == "Circle":
            self.ctrls = cmds.circle(c=(0, 0, 0), nr=(0, 1, 0), sw=360, r=1, d=3, ut=0, tol=0.0001, s=8, ch=1)

        return self.ctrls[0]
Пример #8
0
def makeCurveFromPoints(p, close=True):
	curve = mc.curve(p=p, d=3)
	if close:
		curve = mc.closeCurve(curve, ps=0, rpo=1, bb=0.5, bki=0, p=0.1)
	curve = mc.rebuildCurve(curve, rpo=1, rt=0, end=1, kr=0, kcp=1, kep=1, kt=0, s=4, d=3, tol=0.000129167)
	
	mc.xform(curve, centerPivots=True)
	
	return curve
    def testNurbsCurveGrpReadWrite(self):

        # test w/r of simple Nurbs Curve
        self.__files.append(util.expandFileName('testStaticNurbsCurves.abc'))
        testNurbsCurveRW(self, False, self.__files[-1], 'haka')

        self.__files.append(util.expandFileName('testStaticNurbsCurveGrp.abc'))
        testNurbsCurveRW(self, True, self.__files[-1], 'haka')

        # test if some curves have different degree or close states information
        MayaCmds.file(new=True, force=True)
        name = MayaCmds.textCurves(font='Courier', text='Maya')
        MayaCmds.closeCurve( name[0], replaceOriginal=True )
        MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True)
        self.__files.append(util.expandFileName('testStaticNurbsCurveGrp2.abc'))
        MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], self.__files[-1]))
        MayaCmds.AbcImport(self.__files[-1], mode='open')
        if 'riCurves' in MayaCmds.listAttr(name[0]):
            self.fail(name[0]+".riCurves shouldn't exist")
Пример #10
0
def SK_b30(color = 100):
    if(color == 100):
        color = rig.colorIndexSliderGrp('colorIndexName',q = True,v = True) - 1
    curveName = rig.curve(d = 1,p = [(0,0,4.083750102),(1.074648236,0,4.083750102),(1.074648236,0,-1.916249898),(2.539920287,0,-1.916249898),(0,0,-5.605397886),(-2.539920287,0,-1.916249898),(-1.074648236,0,-1.916249898),(-1.074648236,0,4.083750102)],k = [0,1,2,3,4,5,6,7])
    rig.addAttr(curveName,ln = 'ctrl',at = 'float',min = 0,max = 1, dv = 1) 
    curveNameS = rig.closeCurve(curveName)[0]
    rig.delete(curveName)
    curveNameShape = rig.listRelatives(curveNameS,s = True)[0]
    rig.setAttr(curveNameShape+'.overrideEnabled',1)
    rig.setAttr(curveNameShape+'.overrideColor',color)
    return curveNameS
Пример #11
0
 def drawTriangle(self, t, vertex):
     v1 = vertex[t[0]]
     v2 = vertex[t[1]]
     v3 = vertex[t[2]]
     if len(v1) == 2: v1.append(0)
     if len(v2) == 2: v2.append(0)
     if len(v3) == 2: v3.append(0)
     crv = cmds.curve(p=[v1, v2, v3], d=1)
     crv = cmds.closeCurve(crv, rpo=1)
     cmds.refresh(cv=1)
     return crv
Пример #12
0
	def drawTriangle(self, t, vertex):
		v1 = vertex[t[0]]
		v2 = vertex[t[1]]
		v3 = vertex[t[2]]
		if len(v1)==2: v1.append(0)
		if len(v2)==2: v2.append(0)
		if len(v3)==2: v3.append(0)
		crv = cmds.curve(p=[v1,v2,v3], d=1)
		crv = cmds.closeCurve(crv, rpo=1)
		cmds.refresh(cv=1)
		return crv
Пример #13
0
    def testNurbsCurveGrpReadWrite(self):

        # test w/r of simple Nurbs Curve
        self.__files.append(util.expandFileName('testStaticNurbsCurves.abc'))
        testNurbsCurveRW(self, False, self.__files[-1], 'haka')

        self.__files.append(util.expandFileName('testStaticNurbsCurveGrp.abc'))
        testNurbsCurveRW(self, True, self.__files[-1], 'haka')

        # test if some curves have different degree or close states information
        MayaCmds.file(new=True, force=True)
        name = MayaCmds.textCurves(font='Courier', text='Maya')
        MayaCmds.closeCurve(name[0], replaceOriginal=True)
        MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True)
        self.__files.append(
            util.expandFileName('testStaticNurbsCurveGrp2.abc'))
        MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], self.__files[-1]))
        MayaCmds.AbcImport(self.__files[-1], mode='open')
        if 'riCurves' in MayaCmds.listAttr(name[0]):
            self.fail(name[0] + ".riCurves shouldn't exist")
Пример #14
0
    def CreateCtrlShape(self, shape):
        ''' Changes the look of the generated nurbesCurve based on input '''
        ctrl = None

        if shape == "circle":
            ctrl = cmds.circle(c=[0, 0, 0],
                               nr=[0, 1, 0],
                               sw=360,
                               r=1,
                               d=3,
                               ut=0,
                               tol=0.01,
                               s=8,
                               ch=1)[0]
        elif shape == "flower":
            points = [[-0.3, 0, 0.3], [0, 0, -1.2],
                      [0.3, 0, 0.3], [-1.2, 0, 0], [0.3, 0, -0.3], [0, 0, 1.2],
                      [-0.3, 0, -0.3], [1.2, 0, 0]]
            knots = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
            ctrl = cmds.curve(d=3, p=points, k=knots)
            cmds.closeCurve(ctrl, ch=1, ps=0, rpo=1, bb=0.5, bki=1, p=0)
        elif shape == "square":
            points = [[1, 0, -1], [-1, 0, -1], [-1, 0, 1], [1, 0, 1]]
            knots = [0, 1, 2, 3]
            ctrl = cmds.curve(d=1, p=points, k=knots)
            cmds.closeCurve(ctrl, ch=1, ps=1, rpo=1, bb=0.5, bki=0, p=0.1)
        elif shape == "diamond":
            points = [[0.2, 0, -0.2], [0, 0, -1.2], [-0.2, 0, -0.2],
                      [-1.2, 0, 0], [-0.2, 0, 0.2], [0, 0, 1.2], [0.2, 0, 0.2],
                      [1.2, 0, 0]]
            knots = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
            ctrl = cmds.curve(d=3, p=points, k=knots)
            cmds.closeCurve(ctrl, ch=1, ps=0, rpo=1, bb=0.5, bki=1, p=0)
        else:
            cmds.warning("Invalid shape")

        if ctrl is not None:
            cmds.move(0, 0, 0, ctrl)
        return ctrl
Пример #15
0
def add_curve_shape(shape_choice,
                    transform_node=None,
                    color=None,
                    off_color=False,
                    shape_offset=False):
    """
    Creates a shape node that is input into a transform node.  This will turn a
    transform node into a control shape, allowing for more flexibility in
    building rigging systems that want interchangeable control shape types.
    Shapes may also be assigned a color, to add more distinct appearance.

    Args:
        shape_choice (str): Assigns the shape type for the control.  Availble
            shapes are in the dictionaries listed in the function file.
        transform_node (str): Assigns the transform node that will receive the
            shape node (converting it into a control).  If no input is given,
            will default to the selection.
        color (str) or (list[float, float, float]): Assigns a color value to set
            for the new curve shape.  If string, it must be compatible with the
            keys in rgb_dictionary.  If list, it must have 3 float values that
            correspond with the desired color values in range 0 to 1.
        off_color (bool): If color parameter is a string, all the values in the
            corresponding value list will be cut in half to provide a similar,
            but different color result.  If color parameter is not a string,
            then parameter is benign.
        shape_offset (list[float, float, float]): Assign rotation values for the
            shape to offset its visual direction.  Will have no effect on the
            transform values, only visual feedback of the shape.

    """
    # curve library calling
    if not transform_node:
        transform_node = cmds.ls(selection=True)[0]

    if not transform_node:
        cmds.warning('No input given for the transform_node! Please select an '
                     'object or input a parameter.')
        return

    curve_transform = curve_library[shape_choice]()
    curve_shape = cmds.listRelatives(curve_transform, shapes=True)
    if curve_library_bool[shape_choice]:
        cmds.closeCurve(curve_shape, ch=0, replaceOriginal=1)
    cmds.parent(curve_shape, transform_node, shape=True, r=True)
    cmds.delete(curve_transform)

    # Curve color operations
    if color:
        if color in rgb_dictionary:
            # If an off-color variation is desired, change values to half
            if off_color:
                curve_color = [float(c) / 1.5 for c in rgb_dictionary[color]]
                # Color is a string name used as a key
            else:
                curve_color = rgb_actuals[color]
            set_control_color(rgb_input=curve_color)
        elif type(color) is list:
            # Color is a list of 3 float values
            set_control_color(rgb_input=color)
        else:
            # Neither condition met, no action may be performed
            cmds.warning('Input for "color" parameter is not an acceptable '
                         'value.  Please input one of the appropriate strings '
                         'mentioned in the "help" function, or input a color '
                         'value list like so: [float, float, float].')
            return

    if shape_offset:
        cmds.xform(transform_node + '.cv[0:]', rotation=shape_offset)

    shape_name = cmds.rename(curve_shape, transform_node + 'Shape')
    return shape_name
Пример #16
0
    def testAnimNurbsPlaneWrite(self, wfg=False):

        ret = MayaCmds.nurbsPlane(p=(0, 0, 0), ax=(0, 1, 0), w=1, lr=1, d=3, u=5, v=5, ch=0)
        name = ret[0]

        MayaCmds.lattice(name, dv=(4, 5, 4), oc=True)
        MayaCmds.select("ffd1Lattice.pt[1:2][0:4][1:2]", r=True)

        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(0, 0.18, 0, r=True)
        MayaCmds.scale(2.5, 1.0, 2.5, r=True)
        MayaCmds.setKeyframe()

        MayaCmds.curveOnSurface(
            name,
            uv=((0.597523, 0), (0.600359, 0.271782), (0.538598, 0.564218), (0.496932, 0.779936), (0.672153, 1)),
            k=(0, 0, 0, 0.263463, 0.530094, 0.530094, 0.530094),
        )

        curvename = MayaCmds.curveOnSurface(
            name,
            uv=(
                (0.170718, 0.565967),
                (0.0685088, 0.393034),
                (0.141997, 0.206296),
                (0.95, 0.230359),
                (0.36264, 0.441381),
                (0.251243, 0.569889),
            ),
            k=(0, 0, 0, 0.200545, 0.404853, 0.598957, 0.598957, 0.598957),
        )
        MayaCmds.closeCurve(curvename, ch=1, ps=1, rpo=1, bb=0.5, bki=0, p=0.1, cos=1)

        MayaCmds.trim(name, lu=0.23, lv=0.39)

        degreeU = MayaCmds.getAttr(name + ".degreeU")
        degreeV = MayaCmds.getAttr(name + ".degreeV")
        spansU = MayaCmds.getAttr(name + ".spansU")
        spansV = MayaCmds.getAttr(name + ".spansV")
        formU = MayaCmds.getAttr(name + ".formU")
        formV = MayaCmds.getAttr(name + ".formV")
        minU = MayaCmds.getAttr(name + ".minValueU")
        maxU = MayaCmds.getAttr(name + ".maxValueU")
        minV = MayaCmds.getAttr(name + ".minValueV")
        maxV = MayaCmds.getAttr(name + ".maxValueV")

        MayaCmds.createNode("surfaceInfo")
        MayaCmds.connectAttr(name + ".worldSpace", "surfaceInfo1.inputSurface", force=True)

        MayaCmds.currentTime(1, update=True)
        controlPoints = MayaCmds.getAttr("surfaceInfo1.controlPoints[*]")
        knotsU = MayaCmds.getAttr("surfaceInfo1.knotsU[*]")
        knotsV = MayaCmds.getAttr("surfaceInfo1.knotsV[*]")

        MayaCmds.currentTime(12, update=True)
        controlPoints2 = MayaCmds.getAttr("surfaceInfo1.controlPoints[*]")
        knotsU2 = MayaCmds.getAttr("surfaceInfo1.knotsU[*]")
        knotsV2 = MayaCmds.getAttr("surfaceInfo1.knotsV[*]")

        if wfg:
            self.__files.append(util.expandFileName("testAnimNurbsPlane.abc"))

            MayaCmds.AbcExport(
                j="-fr 1 24 -frs -0.25 -frs 0.0 -frs 0.25 -wfg -root %s -file %s" % (name, self.__files[-1])
            )

            # reading test
            MayaCmds.AbcImport(self.__files[-1], mode="open")
        else:
            self.__files.append(util.expandFileName("testAnimNurbsPlane.abc"))
            self.__files.append(util.expandFileName("testAnimNurbsPlane01_14.abc"))
            self.__files.append(util.expandFileName("testAnimNurbsPlane15_24.abc"))

            MayaCmds.AbcExport(j="-fr 1 14 -root %s -file %s" % (name, self.__files[-2]))
            MayaCmds.AbcExport(j="-fr 15 24 -root %s -file %s" % (name, self.__files[-1]))

            # use AbcStitcher to combine two files into one
            subprocess.call(self.__abcStitcher + self.__files[-3:])

            # reading test
            MayaCmds.AbcImport(self.__files[-3], mode="open")

        self.failUnlessEqual(degreeU, MayaCmds.getAttr(name + ".degreeU"))
        self.failUnlessEqual(degreeV, MayaCmds.getAttr(name + ".degreeV"))
        self.failUnlessEqual(spansU, MayaCmds.getAttr(name + ".spansU"))
        self.failUnlessEqual(spansV, MayaCmds.getAttr(name + ".spansV"))
        self.failUnlessEqual(formU, MayaCmds.getAttr(name + ".formU"))
        self.failUnlessEqual(formV, MayaCmds.getAttr(name + ".formV"))
        self.failUnlessEqual(minU, MayaCmds.getAttr(name + ".minValueU"))
        self.failUnlessEqual(maxU, MayaCmds.getAttr(name + ".maxValueU"))
        self.failUnlessEqual(minV, MayaCmds.getAttr(name + ".minValueV"))
        self.failUnlessEqual(maxV, MayaCmds.getAttr(name + ".maxValueV"))

        MayaCmds.createNode("surfaceInfo")
        MayaCmds.connectAttr(name + ".worldSpace", "surfaceInfo1.inputSurface", force=True)

        MayaCmds.currentTime(1, update=True)
        errmsg = "At frame #1, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints)):
            cp1 = controlPoints[i]
            cp2 = MayaCmds.getAttr("surfaceInfo1.controlPoints[%d]" % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, "x"))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, "y"))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, "z"))

        errmsg = "At frame #1, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU)):
            ku1 = knotsU[i]
            ku2 = MayaCmds.getAttr("surfaceInfo1.knotsU[%d]" % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #1, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV)):
            kv1 = knotsV[i]
            kv2 = MayaCmds.getAttr("surfaceInfo1.knotsV[%d]" % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))

        MayaCmds.currentTime(12, update=True)
        errmsg = "At frame #12, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints2)):
            cp1 = controlPoints2[i]
            cp2 = MayaCmds.getAttr("surfaceInfo1.controlPoints[%d]" % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, "x"))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, "y"))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, "z"))

        errmsg = "At frame #12, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU2)):
            ku1 = knotsU2[i]
            ku2 = MayaCmds.getAttr("surfaceInfo1.knotsU[%d]" % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #12, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV2)):
            kv1 = knotsV2[i]
            kv2 = MayaCmds.getAttr("surfaceInfo1.knotsV[%d]" % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))

        MayaCmds.currentTime(24, update=True)
        errmsg = "At frame #24, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints)):
            cp1 = controlPoints[i]
            cp2 = MayaCmds.getAttr("surfaceInfo1.controlPoints[%d]" % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, "x"))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, "y"))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, "z"))

        errmsg = "At frame #24, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU)):
            ku1 = knotsU[i]
            ku2 = MayaCmds.getAttr("surfaceInfo1.knotsU[%d]" % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #24, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV)):
            kv1 = knotsV[i]
            kv2 = MayaCmds.getAttr("surfaceInfo1.knotsV[%d]" % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))
Пример #17
0
    def testAnimNurbsPlaneWrite(self, wfg=False):

        ret = MayaCmds.nurbsPlane(p=(0, 0, 0), ax=(0, 1, 0), w=1, lr=1, d=3,
            u=5, v=5, ch=0)
        name = ret[0]

        MayaCmds.lattice(name, dv=(4, 5, 4), oc=True)
        MayaCmds.select('ffd1Lattice.pt[1:2][0:4][1:2]', r=True)

        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(0, 0.18, 0, r=True)
        MayaCmds.scale(2.5, 1.0, 2.5, r=True)
        MayaCmds.setKeyframe()

        MayaCmds.curveOnSurface(name,
            uv=((0.597523, 0), (0.600359, 0.271782), (0.538598, 0.564218),
                (0.496932, 0.779936), (0.672153, 1)),
            k=(0, 0, 0, 0.263463, 0.530094, 0.530094, 0.530094))

        curvename = MayaCmds.curveOnSurface(name,
            uv=((0.170718, 0.565967), (0.0685088, 0.393034), (0.141997, 0.206296),
                (0.95, 0.230359), (0.36264, 0.441381), (0.251243, 0.569889)),
            k=(0, 0, 0, 0.200545, 0.404853, 0.598957, 0.598957, 0.598957))
        MayaCmds.closeCurve(curvename, ch=1, ps=1, rpo=1, bb=0.5, bki=0, p=0.1,
            cos=1)

        MayaCmds.trim(name, lu=0.23, lv=0.39)

        degreeU = MayaCmds.getAttr(name + '.degreeU')
        degreeV = MayaCmds.getAttr(name + '.degreeV')
        spansU = MayaCmds.getAttr(name + '.spansU')
        spansV = MayaCmds.getAttr(name + '.spansV')
        formU = MayaCmds.getAttr(name + '.formU')
        formV = MayaCmds.getAttr(name + '.formV')
        minU = MayaCmds.getAttr(name + '.minValueU')
        maxU = MayaCmds.getAttr(name + '.maxValueU')
        minV = MayaCmds.getAttr(name + '.minValueV')
        maxV = MayaCmds.getAttr(name + '.maxValueV')

        MayaCmds.createNode('surfaceInfo')
        MayaCmds.connectAttr(name + '.worldSpace', 'surfaceInfo1.inputSurface',
            force=True)

        MayaCmds.currentTime(1, update=True)
        controlPoints = MayaCmds.getAttr('surfaceInfo1.controlPoints[*]')
        knotsU = MayaCmds.getAttr('surfaceInfo1.knotsU[*]')
        knotsV = MayaCmds.getAttr('surfaceInfo1.knotsV[*]')

        MayaCmds.currentTime(12, update=True)
        controlPoints2 = MayaCmds.getAttr('surfaceInfo1.controlPoints[*]')
        knotsU2 = MayaCmds.getAttr('surfaceInfo1.knotsU[*]')
        knotsV2 = MayaCmds.getAttr('surfaceInfo1.knotsV[*]')

        if wfg:
            self.__files.append(util.expandFileName('testAnimNurbsPlane.abc'))

            MayaCmds.AbcExport(j='-fr 1 24 -frs -0.25 -frs 0.0 -frs 0.25 -wfg -root %s -file %s' % (name, self.__files[-1]))

            # reading test
            MayaCmds.AbcImport(self.__files[-1], mode='open')
        else:
            self.__files.append(util.expandFileName('testAnimNurbsPlane.abc'))
            self.__files.append(util.expandFileName('testAnimNurbsPlane01_14.abc'))
            self.__files.append(util.expandFileName('testAnimNurbsPlane15_24.abc'))

            MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' % (name, self.__files[-2]))
            MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' % (name, self.__files[-1]))

            # use AbcStitcher to combine two files into one
            subprocess.call(self.__abcStitcher + self.__files[-3:])

            # reading test
            MayaCmds.AbcImport(self.__files[-3], mode='open')

        self.failUnlessEqual(degreeU, MayaCmds.getAttr(name + '.degreeU'))
        self.failUnlessEqual(degreeV, MayaCmds.getAttr(name + '.degreeV'))
        self.failUnlessEqual(spansU, MayaCmds.getAttr(name + '.spansU'))
        self.failUnlessEqual(spansV, MayaCmds.getAttr(name + '.spansV'))
        self.failUnlessEqual(formU, MayaCmds.getAttr(name + '.formU'))
        self.failUnlessEqual(formV, MayaCmds.getAttr(name + '.formV'))
        self.failUnlessEqual(minU, MayaCmds.getAttr(name + '.minValueU'))
        self.failUnlessEqual(maxU, MayaCmds.getAttr(name + '.maxValueU'))
        self.failUnlessEqual(minV, MayaCmds.getAttr(name + '.minValueV'))
        self.failUnlessEqual(maxV, MayaCmds.getAttr(name + '.maxValueV'))

        MayaCmds.createNode('surfaceInfo')
        MayaCmds.connectAttr(name + '.worldSpace', 'surfaceInfo1.inputSurface',
            force=True)

        MayaCmds.currentTime(1, update=True)
        errmsg = "At frame #1, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints)):
            cp1 = controlPoints[i]
            cp2 = MayaCmds.getAttr('surfaceInfo1.controlPoints[%d]' % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, 'x'))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, 'y'))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, 'z'))

        errmsg = "At frame #1, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU)):
            ku1 = knotsU[i]
            ku2 = MayaCmds.getAttr('surfaceInfo1.knotsU[%d]' % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #1, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV)):
            kv1 = knotsV[i]
            kv2 = MayaCmds.getAttr('surfaceInfo1.knotsV[%d]' % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))

        MayaCmds.currentTime(12, update=True)
        errmsg = "At frame #12, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints2)):
            cp1 = controlPoints2[i]
            cp2 = MayaCmds.getAttr('surfaceInfo1.controlPoints[%d]' % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, 'x'))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, 'y'))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, 'z'))

        errmsg = "At frame #12, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU2)):
            ku1 = knotsU2[i]
            ku2 = MayaCmds.getAttr('surfaceInfo1.knotsU[%d]' % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #12, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV2)):
            kv1 = knotsV2[i]
            kv2 = MayaCmds.getAttr('surfaceInfo1.knotsV[%d]' % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))

        MayaCmds.currentTime(24, update=True)
        errmsg = "At frame #24, Nurbs Plane's control point #%d.%s not equal"
        for i in range(0, len(controlPoints)):
            cp1 = controlPoints[i]
            cp2 = MayaCmds.getAttr('surfaceInfo1.controlPoints[%d]' % (i))
            self.failUnlessAlmostEqual(cp1[0], cp2[0][0], 3, errmsg % (i, 'x'))
            self.failUnlessAlmostEqual(cp1[1], cp2[0][1], 3, errmsg % (i, 'y'))
            self.failUnlessAlmostEqual(cp1[2], cp2[0][2], 3, errmsg % (i, 'z'))

        errmsg = "At frame #24, Nurbs Plane's control knotsU #%d not equal"
        for i in range(0, len(knotsU)):
            ku1 = knotsU[i]
            ku2 = MayaCmds.getAttr('surfaceInfo1.knotsU[%d]' % (i))
            self.failUnlessAlmostEqual(ku1, ku2, 3, errmsg % (i))

        errmsg = "At frame #24, Nurbs Plane's control knotsV #%d not equal"
        for i in range(0, len(knotsV)):
            kv1 = knotsV[i]
            kv2 = MayaCmds.getAttr('surfaceInfo1.knotsV[%d]' % (i))
            self.failUnlessAlmostEqual(kv1, kv2, 3, errmsg % (i))
Пример #18
0
def testStaticNurbsWithOneCloseCurveTrim(self, surfacetype, abcFileName,
                                         trimtype):

    if (surfacetype == 0):
        ret = MayaCmds.nurbsPlane(p=(0, 0, 0),
                                  ax=(0, 1, 0),
                                  w=1,
                                  lr=1,
                                  d=3,
                                  u=5,
                                  v=5,
                                  ch=0)
    elif (surfacetype == 1):
        ret = MayaCmds.sphere(p=(0, 0, 0),
                              ax=(0, 1, 0),
                              ssw=0,
                              esw=360,
                              r=1,
                              d=3,
                              ut=0,
                              tol=0.01,
                              s=8,
                              nsp=4,
                              ch=0)
    elif (surfacetype == 2):
        ret = MayaCmds.torus(p=(0, 0, 0),
                             ax=(0, 1, 0),
                             ssw=0,
                             esw=360,
                             msw=360,
                             r=1,
                             hr=0.5,
                             ch=0)

    name = ret[0]

    MayaCmds.curveOnSurface(name,
                            uv=((0.170718, 0.565967), (0.0685088, 0.393034),
                                (0.141997, 0.206296), (0.95, 0.230359),
                                (0.36264, 0.441381), (0.251243, 0.569889)),
                            k=(0, 0, 0, 0.200545, 0.404853, 0.598957, 0.598957,
                               0.598957))
    MayaCmds.closeCurve(name + '->curve1',
                        ch=1,
                        ps=1,
                        rpo=1,
                        bb=0.5,
                        bki=0,
                        p=0.1,
                        cos=1)

    if trimtype == 0:
        MayaCmds.trim(name, lu=0.68, lv=0.39)
    elif 1:
        MayaCmds.trim(name, lu=0.267062, lv=0.39475)

    degreeU = MayaCmds.getAttr(name + '.degreeU')
    degreeV = MayaCmds.getAttr(name + '.degreeV')
    spansU = MayaCmds.getAttr(name + '.spansU')
    spansV = MayaCmds.getAttr(name + '.spansV')
    formU = MayaCmds.getAttr(name + '.formU')
    formV = MayaCmds.getAttr(name + '.formV')
    minU = MayaCmds.getAttr(name + '.minValueU')
    maxU = MayaCmds.getAttr(name + '.maxValueU')
    minV = MayaCmds.getAttr(name + '.minValueV')
    maxV = MayaCmds.getAttr(name + '.maxValueV')

    surfaceInfoNode = MayaCmds.createNode('surfaceInfo')
    MayaCmds.connectAttr(name + '.worldSpace',
                         surfaceInfoNode + '.inputSurface',
                         force=True)

    controlPoints = MayaCmds.getAttr(surfaceInfoNode + '.controlPoints[*]')
    knotsU = MayaCmds.getAttr(surfaceInfoNode + '.knotsU[*]')
    knotsV = MayaCmds.getAttr(surfaceInfoNode + '.knotsV[*]')

    MayaCmds.AbcExport(j='-root %s -f %s' % (name, abcFileName))
    MayaCmds.AbcImport(abcFileName, mode='open')

    self.failUnlessEqual(degreeU, MayaCmds.getAttr(name + '.degreeU'))
    self.failUnlessEqual(degreeV, MayaCmds.getAttr(name + '.degreeV'))
    self.failUnlessEqual(spansU, MayaCmds.getAttr(name + '.spansU'))
    self.failUnlessEqual(spansV, MayaCmds.getAttr(name + '.spansV'))
    self.failUnlessEqual(minU, MayaCmds.getAttr(name + '.minValueU'))
    self.failUnlessEqual(maxU, MayaCmds.getAttr(name + '.maxValueU'))
    self.failUnlessEqual(minV, MayaCmds.getAttr(name + '.minValueV'))
    self.failUnlessEqual(maxV, MayaCmds.getAttr(name + '.maxValueV'))

    surfaceInfoNode = MayaCmds.createNode('surfaceInfo')
    MayaCmds.connectAttr(name + '.worldSpace',
                         surfaceInfoNode + '.inputSurface',
                         force=True)

    controlPoints2 = MayaCmds.getAttr(surfaceInfoNode + '.controlPoints[*]')
    self.failUnlessEqual(len(controlPoints), len(controlPoints2))
    for i in range(0, len(controlPoints)):
        cp1 = controlPoints[i]
        cp2 = controlPoints2[i]
        self.failUnlessAlmostEqual(cp1[0], cp2[0], 3, 'cp[%d].x not equal' % i)
        self.failUnlessAlmostEqual(cp1[1], cp2[1], 3, 'cp[%d].y not equal' % i)
        self.failUnlessAlmostEqual(cp1[2], cp2[2], 3, 'cp[%d].z not equal' % i)

    for i in range(0, len(knotsU)):
        ku1 = knotsU[i]
        ku2 = MayaCmds.getAttr('surfaceInfo1.knotsU[%d]' % i)
        self.failUnlessAlmostEqual(ku1, ku2, 3,
                                   'control knotsU # %d not equal' % i)

    for i in range(0, len(knotsV)):
        kv1 = knotsV[i]
        kv2 = MayaCmds.getAttr('surfaceInfo1.knotsV[%d]' % i)
        self.failUnlessAlmostEqual(kv1, kv2, 3,
                                   'control knotsV # %d not equal' % i)
Пример #19
0
def createControl(name="default",type="circle", axis="x", color="darkBlue", *args):
	"""
	creates control namemed by first arg, at origin.
	shape is determined by second arg: "cube", "octagon", "sphere", "diamond", "barbell",
	third arg can be 'x',, 'y', , 'z'  and is the axis along which the control lies.
	The colors are: 'lightBlue', 'darkGreen', 'lightPurple', 'yellow', 'darkPurple', 'pink', 'blue', 'purple', 'lightGreen', 'black', 'orange', 'white', 'darkYellow', 'brown', 'lightYellow', 'darkBlue', 'royalBlue', 'darkBrown', 'lightRed', 'medBlue', 'lightBrown', 'darkRed', 'yellowGreen', 'medGreen', 'green', 'red'
	Arguments: name, type, axis, color
	"""
	colors = {}
	colors["red"]=13
	colors["blue"]=6
	colors["green"]=14
	colors["darkRed"]=4
	colors["lightRed"]=31
	colors["darkBlue"]=5
	colors["medBlue"]=15
	colors["lightBlue"]=18
	colors["royalBlue"]=29
	colors["darkGreen"]=7
	colors["medGreen"]=27
	colors["lightGreen"]=19
	colors["yellowGreen"]=26
	colors["yellow"]=17
	colors["darkYellow"]=21
	colors["lightYellow"]=22
	colors["purple"]=30
	colors["lightPurple"]=9
	colors["darkPurple"]=8
	colors["black"]=1
	colors["white"]=16
	colors["brown"]=10
	colors["darkBrown"]=11
	colors["lightBrown"]=24
	colors["pink"]=20
	colors["orange"] =12

	#deal with axis, x is default
	if axis == "x":
		rot = (0, 0, 0)
	elif axis == "y":
		rot = (0, 0, 90)
	elif axis =="z":
		rot = (0, 90, 0)
	else:
		cmds.warning('createControl: you entered an incorrect axis. Must be x, y or z')

	#-------------------------do this from dictionary, that way it's easier to control the flow to error or return
	if type == "circle":
		cmds.circle(n=name, nr= (1,0,0))

	elif type == "cube":
		cmds.curve(n=name, d=1, p=[[-0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, -1.0031016006564133]])

	elif type == "octagon":
		cmds.curve(n=name, d=1, p=[[-7.4559598726027055e-17, 0.70710670948028576, 0.70710670948028564], [5.5511098291698525e-17, 0.99999988079071067, 0.0], [-7.4559598726027055e-17, 0.70710670948028576, -0.70710670948028564], [-3.8857805861880489e-16, 1.7256332301709633e-31, -0.99999988079071045], [-7.0259651851158272e-16, -0.70710670948028576, -0.70710670948028564], [-8.326672684688675e-16, -1.0000000000000002, 0.0], [-7.0259654498136232e-16, -0.70710676908493053, 0.70710676908493042], [-3.8857805861880489e-16, 1.7256332301709633e-31, 0.99999994039535522], [-7.4559598726027055e-17, 0.70710670948028576, 0.70710670948028564]])

	elif type == "barbell":
		cmds.curve(n=name, d=3, p=[[0.57752510285324732, 5.5507632834890673e-17, -0.90650843775588597], [-2.9672778948456972e-16, 6.4094693518606145e-17, -1.661011590594498], [-0.57752510285324554, 5.550763283489071e-17, -0.90650843775588663], [-0.29814028408909887, 1.0540006765710255e-17, -0.67397322551417882], [-0.14033645814277884, -1.3393164286098273e-33, -2.7549060854235934e-16], [-0.29814028408909921, -1.0540006765710255e-17, 0.67397322551417838], [-0.57752510285324621, -5.5507632834890697e-17, 0.90650843775588641], [-6.6071759651022318e-16, -6.4094693518606133e-17, 1.6610115905944978], [0.57752510285324488, -5.550763283489074e-17, 0.90650843775588708], [0.29814028408909876, -1.0540006765710279e-17, 0.67397322551417937], [0.14033645814277884, -2.8148100723370156e-32, 8.7651446050535732e-16], [0.29814028408909921, 1.0540006765710236e-17, -0.6739732255141776]])
		cmds.closeCurve(name, ch=False, ps=False, rpo=True, bki=True)

	elif type == "sphere":
		cmds.curve(n=name, d=1, p=[[0.0, 1.0, 0.0], [-0.382683, 0.92388000000000003, 0.0], [-0.70710700000000004, 0.70710700000000004, 0.0], [-0.92388000000000003, 0.382683, 0.0], [-1.0, 0.0, 0.0], [-0.92388000000000003, -0.382683, 0.0], [-0.70710700000000004, -0.70710700000000004, 0.0], [-0.382683, -0.92388000000000003, 0.0], [0.0, -1.0, 0.0], [0.382683, -0.92388000000000003, 0.0], [0.70710700000000004, -0.70710700000000004, 0.0], [0.92388000000000003, -0.382683, 0.0], [1.0, 0.0, 0.0], [0.92388000000000003, 0.382683, 0.0], [0.70710700000000004, 0.70710700000000004, 0.0], [0.382683, 0.92388000000000003, 0.0], [0.0, 1.0, 0.0], [0.0, 0.92388000000000003, 0.382683], [0.0, 0.70710700000000004, 0.70710700000000004], [0.0, 0.382683, 0.92388000000000003], [0.0, 0.0, 1.0], [0.0, -0.382683, 0.92388000000000003], [0.0, -0.70710700000000004, 0.70710700000000004], [0.0, -0.92388000000000003, 0.382683], [0.0, -1.0, 0.0], [0.0, -0.92388000000000003, -0.382683], [0.0, -0.70710700000000004, -0.70710700000000004], [0.0, -0.382683, -0.92388000000000003], [0.0, 0.0, -1.0], [0.0, 0.382683, -0.92388000000000003], [0.0, 0.70710700000000004, -0.70710700000000004], [0.0, 0.92388000000000003, -0.382683], [0.0, 1.0, 0.0], [-0.382683, 0.92388000000000003, 0.0], [-0.70710700000000004, 0.70710700000000004, 0.0], [-0.92388000000000003, 0.382683, 0.0], [-1.0, 0.0, 0.0], [-0.92388000000000003, 0.0, 0.382683], [-0.70710700000000004, 0.0, 0.70710700000000004], [-0.382683, 0.0, 0.92388000000000003], [0.0, 0.0, 1.0], [0.382683, 0.0, 0.92388000000000003], [0.70710700000000004, 0.0, 0.70710700000000004], [0.92388000000000003, 0.0, 0.382683], [1.0, 0.0, 0.0], [0.92388000000000003, 0.0, -0.382683], [0.70710700000000004, 0.0, -0.70710700000000004], [0.382683, 0.0, -0.92388000000000003], [0.0, 0.0, -1.0], [-0.382683, 0.0, -0.92388000000000003], [-0.70710700000000004, 0.0, -0.70710700000000004], [-0.92388000000000003, 0.0, -0.382683], [-1.0, 0.0, 0.0]])


	elif type=="diamond":
		cmds.curve(n=name, d=1, p=[[3.1401849173675503e-16, 0.70710678118654768, 1.1102230246251565e-16], [4.9303806576313238e-32, 1.1102230246251568e-16, -0.70710678118654757], [-3.1401849173675503e-16, -0.70710678118654768, -1.1102230246251565e-16], [-4.9303806576313238e-32, -1.1102230246251568e-16, 0.70710678118654757], [3.1401849173675503e-16, 0.70710678118654768, 1.1102230246251565e-16]])

	else:
		cmds.warning("createControl doesn't know shape - '%s'"%type)

	#rotate to axis
	cmds.select(name+".cv[*]")
	cmds.rotate(rot[0], rot[1], rot[2], r=True)
	cmds.select(cl=True)
	shapes = cmds.listRelatives(name, shapes=True)
	for shape in shapes:
		cmds.setAttr("%s.overrideEnabled"%shape, 1)
		cmds.setAttr("%s.overrideColor"%shape, colors[color])
	#return the name of the curve
	return(name)
Пример #20
0
	def triangulate(self, outType="curves", timer=0):
		"Makes all calculation. You can specify the output type (curves or faces) and if you want to set a timer to see consumed time in the operation"
		
		#check if you want to display time consumed for the operation:
		if timer: currTime = datetime.datetime.now()
		
		#create an empty triangle list
		triangles = []
		#and en empty list to store vertexes in order
		vertex = []
		
		##we need to start with a supertriangle which encompasses all the points
		##this is done by getting the minimum and maximum bounds of all points
		##and by adding a triangle to the triangles list which is a tad bigger than this bounds
		#copy the vertices list
		vs = self.vertices
		vertex.extend(vs)
		#make a series of operations to find minimum and maximum x and y values
		xmin = vs[0][0]
		ymin = vs[0][1]
		xmax = xmin
		ymax = ymin
		for i in range(self.numPoints):
			if vs[i][0] < xmin: xmin = vs[i][0]
			if vs[i][0] > xmax: xmax = vs[i][0]
			if vs[i][1] < ymin: ymin = vs[i][1]
			if vs[i][1] > ymax: ymax = vs[i][1] 
		#get min and max distances
		dx = xmax-xmin
		dy = ymax-ymin
		if dx > dy:
			dmax = dx
		else:
			dmax = dy
		#get mid points of these distances
		xmid = (xmax+xmin)/2
		ymid = (ymax+ymin)/2
		
		#calculate the coordinates of the vertices of the supertriangle
		#and add them to the end of the vertex list
		#and add this triangle to the triangles list (it is the first)
		v1x = xmid - 2*dmax
		v1y = ymid - dmax
		vertex.append([v1x, v1y])
		v2x = xmid
		v2y = ymid + 2*dmax
		vertex.append([v2x, v2y])
		v3x = xmid + 2*dmax
		v3y = ymid - dmax
		vertex.append([v3x, v3y])		
		triangles.append([self.numPoints,self.numPoints+1,self.numPoints+2])
		
		##having already one triangle in the triangles list, we can start adding points
		##and re-triangulate everytime we need
		
		#progress window > initialize before the loop
		cmds.progressWindow(title='Creating Delaunay regions...', #here you input your message for the progress window/can be anything
							minValue=0,
							maxValue=self.numPoints,    # this is imporant: when will the progress be 100%?
							status='Points left: %d' % self.numPoints,  # here is some status message /anything you want
							isInterruptable=True )
		
		#Include each point one at a time into the existing triangulations
		for i in range(len(vertex)):
			#if i is more than the original number of points, stop loop 
			#cos then it is a vertex of the supertriangle, and we don't need to calculate them
			if i >= self.numPoints: break
			#get current point i coordinates
			p = vertex[i]
			#Set up the edge buffer.
			#If the point (x,y) lies inside the circumcircle formed by each triangle, 
			#then the three edges of that triangle are added to the edge buffer.
			edges = []
			
			#create a copy of the triangles list to loop through
			tcopy = []
			tcopy.extend(triangles)
			#loop through the triangles to check the points
			for t in tcopy:
				#if the triangle is composed by the vertex in question (i), skip
				if i in t: continue
				#convert the triangle vertices to a list of coordinates
				tri=[ [vertex[k][0], vertex[k][1]] for k in t ]
				#check if the point i is in the circle formed by this triangle
				ic = self.inCircle(point=[p[0], p[1]], triangle=tri)
				if ic:
					#in case ic == true:
					#store the edges in the edges list
					edges.append([t[0], t[1]])
					edges.append([t[1], t[2]])
					edges.append([t[2], t[0]])
					#remove triangle from triangle list
					triangles.remove(t)
			
			#delete all duplicate edges from the edge buffer
			#this leaves the edges of the enclosing polygon only
			edges = removeDuplicates(edges)

			#add to the triangle list all triangles formed between the point
			#and the edges of the enclosing polygon (from the edge buffer
			for j in range(len(edges)):
				v1 = edges[j][0]
				v2 = edges[j][1]
				v3 = i
				triangles.append([v1,v2,v3])
			
			#update progress window
			if cmds.progressWindow( query=True, isCancelled=True ) : break
			cmds.progressWindow( edit=True, step=1, status=('Points left: %d' % (self.numPoints-i)) ) 
			
		#end loop for vertices
		
		###FINAL STEP
		#now draw the triangles defined in the triangels list
		for t in triangles:
			#check if this triangle does not belong to the supertriangle,
			#if it does, jump
			if t[0] > self.numPoints-1 or t[1] > self.numPoints-1 or t[2] > self.numPoints-1: continue
			#get coordinates of the triangle t
			v1 = vertex[t[0]]
			v2 = vertex[t[1]]
			v3 = vertex[t[2]]
			#see if all coordinates contain the Z value, if not, add z=0
			if len(v1)==2: v1.append(0)
			if len(v2)==2: v2.append(0)
			if len(v3)==2: v3.append(0)
			#draw the curve
			crv = cmds.curve(p=[v1,v2,v3], d=1)
			crv = cmds.closeCurve(crv, rpo=1)
			#if outType is specified as "faces", draw the face
			if outType == "faces": cmds.planarSrf(crv)
			#to see in real time, uncomment the line below (increase operation time by circa 5 times)
			#cmds.refresh(cv=1)
		
		#end progress window
		cmds.progressWindow(endProgress=1)
		
		#feedback
		print "Delaunay triangulations created successfully!"
		print ">> %d points" % self.numPoints
		print ">> %d triangles" % len(triangles)
		#check if you want to see time consumed
		if timer: 
			delta_t = datetime.datetime.now() - currTime 
			print ">> Time consumed: %s" % str(delta_t)
Пример #21
0
def createControl(name="default",type="circle", axis="x", color="darkBlue", *args):
	"""
	creates control namemed by first arg, at origin.
	shape is determined by second arg: "cube", "octagon", "sphere", "diamond", "barbell",
	third arg can be 'x',, 'y', , 'z'  and is the axis along which the control lies.
	The colors are: 'lightBlue', 'darkGreen', 'lightPurple', 'yellow', 'darkPurple', 'pink', 'blue', 'purple', 'lightGreen', 'black', 'orange', 'white', 'darkYellow', 'brown', 'lightYellow', 'darkBlue', 'royalBlue', 'darkBrown', 'lightRed', 'medBlue', 'lightBrown', 'darkRed', 'yellowGreen', 'medGreen', 'green', 'red'
	Arguments: name, type, axis, color
	"""
	colors = {}
	colors["red"]=13
	colors["blue"]=6
	colors["green"]=14
	colors["darkRed"]=4
	colors["lightRed"]=31
	colors["darkBlue"]=5
	colors["medBlue"]=15
	colors["lightBlue"]=18
	colors["royalBlue"]=29
	colors["darkGreen"]=7
	colors["medGreen"]=27
	colors["lightGreen"]=19
	colors["yellowGreen"]=26
	colors["yellow"]=17
	colors["darkYellow"]=21
	colors["lightYellow"]=22
	colors["purple"]=30
	colors["lightPurple"]=9
	colors["darkPurple"]=8
	colors["black"]=1
	colors["white"]=16
	colors["brown"]=10
	colors["darkBrown"]=11
	colors["lightBrown"]=24
	colors["pink"]=20
	colors["orange"] =12

	#deal with axis, x is default
	if axis == "x":
		rot = (0, 0, 0)
	elif axis == "y":
		rot = (0, 0, 90)
	elif axis =="z":
		rot = (0, 90, 0)
	else:
		cmds.warning('createControl: you entered an incorrect axis. Must be x, y or z')

	#-------------------------do this from dictionary, that way it's easier to control the flow to error or return
	if type == "circle":
		ctrl = cmds.circle(n=name, nr= (1,0,0))

	elif type == "cube":
		ctrl = cmds.curve(n=name, d=1, p=[[-0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, 1.0031016006564133], [0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, 1.0031016006564133, -1.0031016006564133], [-0.34095753069042323, -1.0031016006564133, -1.0031016006564133], [0.34095753069042323, -1.0031016006564133, -1.0031016006564133]])

	elif type == "octagon":
		ctrl = cmds.curve(n=name, d=1, p=[[-7.4559598726027055e-17, 0.70710670948028576, 0.70710670948028564], [5.5511098291698525e-17, 0.99999988079071067, 0.0], [-7.4559598726027055e-17, 0.70710670948028576, -0.70710670948028564], [-3.8857805861880489e-16, 1.7256332301709633e-31, -0.99999988079071045], [-7.0259651851158272e-16, -0.70710670948028576, -0.70710670948028564], [-8.326672684688675e-16, -1.0000000000000002, 0.0], [-7.0259654498136232e-16, -0.70710676908493053, 0.70710676908493042], [-3.8857805861880489e-16, 1.7256332301709633e-31, 0.99999994039535522], [-7.4559598726027055e-17, 0.70710670948028576, 0.70710670948028564]])

	elif type == "barbell":
		ctrl = cmds.curve(n=name, d=3, p=[[0.57752510285324732, 5.5507632834890673e-17, -0.90650843775588597], [-2.9672778948456972e-16, 6.4094693518606145e-17, -1.661011590594498], [-0.57752510285324554, 5.550763283489071e-17, -0.90650843775588663], [-0.29814028408909887, 1.0540006765710255e-17, -0.67397322551417882], [-0.14033645814277884, -1.3393164286098273e-33, -2.7549060854235934e-16], [-0.29814028408909921, -1.0540006765710255e-17, 0.67397322551417838], [-0.57752510285324621, -5.5507632834890697e-17, 0.90650843775588641], [-6.6071759651022318e-16, -6.4094693518606133e-17, 1.6610115905944978], [0.57752510285324488, -5.550763283489074e-17, 0.90650843775588708], [0.29814028408909876, -1.0540006765710279e-17, 0.67397322551417937], [0.14033645814277884, -2.8148100723370156e-32, 8.7651446050535732e-16], [0.29814028408909921, 1.0540006765710236e-17, -0.6739732255141776]])
		cmds.closeCurve(name, ch=False, ps=False, rpo=True, bki=True)

	elif type == "sphere":
		ctrl = cmds.curve(n=name, d=1, p=[[0.0, 1.0, 0.0], [-0.382683, 0.92388000000000003, 0.0], [-0.70710700000000004, 0.70710700000000004, 0.0], [-0.92388000000000003, 0.382683, 0.0], [-1.0, 0.0, 0.0], [-0.92388000000000003, -0.382683, 0.0], [-0.70710700000000004, -0.70710700000000004, 0.0], [-0.382683, -0.92388000000000003, 0.0], [0.0, -1.0, 0.0], [0.382683, -0.92388000000000003, 0.0], [0.70710700000000004, -0.70710700000000004, 0.0], [0.92388000000000003, -0.382683, 0.0], [1.0, 0.0, 0.0], [0.92388000000000003, 0.382683, 0.0], [0.70710700000000004, 0.70710700000000004, 0.0], [0.382683, 0.92388000000000003, 0.0], [0.0, 1.0, 0.0], [0.0, 0.92388000000000003, 0.382683], [0.0, 0.70710700000000004, 0.70710700000000004], [0.0, 0.382683, 0.92388000000000003], [0.0, 0.0, 1.0], [0.0, -0.382683, 0.92388000000000003], [0.0, -0.70710700000000004, 0.70710700000000004], [0.0, -0.92388000000000003, 0.382683], [0.0, -1.0, 0.0], [0.0, -0.92388000000000003, -0.382683], [0.0, -0.70710700000000004, -0.70710700000000004], [0.0, -0.382683, -0.92388000000000003], [0.0, 0.0, -1.0], [0.0, 0.382683, -0.92388000000000003], [0.0, 0.70710700000000004, -0.70710700000000004], [0.0, 0.92388000000000003, -0.382683], [0.0, 1.0, 0.0], [-0.382683, 0.92388000000000003, 0.0], [-0.70710700000000004, 0.70710700000000004, 0.0], [-0.92388000000000003, 0.382683, 0.0], [-1.0, 0.0, 0.0], [-0.92388000000000003, 0.0, 0.382683], [-0.70710700000000004, 0.0, 0.70710700000000004], [-0.382683, 0.0, 0.92388000000000003], [0.0, 0.0, 1.0], [0.382683, 0.0, 0.92388000000000003], [0.70710700000000004, 0.0, 0.70710700000000004], [0.92388000000000003, 0.0, 0.382683], [1.0, 0.0, 0.0], [0.92388000000000003, 0.0, -0.382683], [0.70710700000000004, 0.0, -0.70710700000000004], [0.382683, 0.0, -0.92388000000000003], [0.0, 0.0, -1.0], [-0.382683, 0.0, -0.92388000000000003], [-0.70710700000000004, 0.0, -0.70710700000000004], [-0.92388000000000003, 0.0, -0.382683], [-1.0, 0.0, 0.0]])

	elif type=="diamond":
		ctrl = cmds.curve(n=name, d=1, p=[[3.1401849173675503e-16, 0.70710678118654768, 1.1102230246251565e-16], [4.9303806576313238e-32, 1.1102230246251568e-16, -0.70710678118654757], [-3.1401849173675503e-16, -0.70710678118654768, -1.1102230246251565e-16], [-4.9303806576313238e-32, -1.1102230246251568e-16, 0.70710678118654757], [3.1401849173675503e-16, 0.70710678118654768, 1.1102230246251565e-16]])

	else:
		cmds.warning("createControl doesn't know shape - '%s'"%type)

	#rotate to axis
	cmds.select("{0}.cv[*]".format(ctrl))
	cmds.rotate(rot[0], rot[1], rot[2], r=True)
	cmds.select(cl=True)
	shapes = cmds.listRelatives(ctrl, shapes=True)
	for shape in shapes:
		cmds.setAttr("%s.overrideEnabled"%shape, 1)
		cmds.setAttr("%s.overrideColor"%shape, colors[color])
		cmds.rename(shape, "{0}Shape".format(ctrl))
		print "ctrl shape is: {0}".format(shape)
	#return the name of the curve
	return(ctrl)
Пример #22
0
    (-0.575, 0.0, -0.102), (-0.568, 0.0, -0.102), (-0.521, 0.0, -0.102),
    (-0.514, 0.0, -0.102), (-0.473, 0.0, -0.31), (-0.31, 0.0, -0.473),
    (-0.102, 0.0, -0.514), (-0.102, 0.0, -0.521), (-0.102, 0.0, -0.568),
    (-0.102, 0.0, -0.575), (-0.116, 0.0, -0.575), (-0.209, 0.0, -0.575),
    (-0.223, 0.0, -0.575), (-0.198, 0.0, -0.618), (-0.024, 0.0, -0.917),
    (0.0, 0.0, -0.96), (0.024, 0.0, -0.917), (0.198, 0.0, -0.618),
    (0.223, 0.0, -0.575), (0.209, 0.0, -0.575), (0.116, 0.0, -0.575),
    (0.102, 0.0, -0.575), (0.102, 0.0, -0.568), (0.102, 0.0, -0.521),
    (0.102, 0.0, -0.514), (0.31, 0.0, -0.473), (0.473, 0.0, -0.31),
    (0.514, 0.0, -0.102), (0.521, 0.0, -0.102), (0.568, 0.0, -0.102),
    (0.575, 0.0, -0.102), (0.575, 0.0, -0.116), (0.575, 0.0, -0.209),
    (0.575, 0.0, -0.223), (0.618, 0.0, -0.198)
]

master_crv = cmds.curve(name='master_crv', p=master_points)
cmds.closeCurve(ps=0, ch=0, rpo=1)

paintCurve('master_crv', c)

cmds.parent(master_crv, main_group)

master = BodyPart('master', c, 'master_crv')

# ROOT/HIP
# ----------------
root_crv = cmds.circle(name='root_center_crv', radius=0.18)
cmds.move(0, 1.102, 0)
cmds.rotate(90, 0, 0)
paintCurve('root_center_crv', c)

root_geo = cmds.polyCube(name='root_center_geo', sy=2, sx=2)
Пример #23
0
    def triangulate(self, outType="curves", timer=0):
        "Makes all calculation. You can specify the output type (curves or faces) and if you want to set a timer to see consumed time in the operation"

        #check if you want to display time consumed for the operation:
        if timer: currTime = datetime.datetime.now()

        #create an empty triangle list
        triangles = []
        #and en empty list to store vertexes in order
        vertex = []

        ##we need to start with a supertriangle which encompasses all the points
        ##this is done by getting the minimum and maximum bounds of all points
        ##and by adding a triangle to the triangles list which is a tad bigger than this bounds
        #copy the vertices list
        vs = self.vertices
        vertex.extend(vs)
        #make a series of operations to find minimum and maximum x and y values
        xmin = vs[0][0]
        ymin = vs[0][1]
        xmax = xmin
        ymax = ymin
        for i in range(self.numPoints):
            if vs[i][0] < xmin: xmin = vs[i][0]
            if vs[i][0] > xmax: xmax = vs[i][0]
            if vs[i][1] < ymin: ymin = vs[i][1]
            if vs[i][1] > ymax: ymax = vs[i][1]
        #get min and max distances
        dx = xmax - xmin
        dy = ymax - ymin
        if dx > dy:
            dmax = dx
        else:
            dmax = dy
        #get mid points of these distances
        xmid = (xmax + xmin) / 2
        ymid = (ymax + ymin) / 2

        #calculate the coordinates of the vertices of the supertriangle
        #and add them to the end of the vertex list
        #and add this triangle to the triangles list (it is the first)
        v1x = xmid - 2 * dmax
        v1y = ymid - dmax
        vertex.append([v1x, v1y])
        v2x = xmid
        v2y = ymid + 2 * dmax
        vertex.append([v2x, v2y])
        v3x = xmid + 2 * dmax
        v3y = ymid - dmax
        vertex.append([v3x, v3y])
        triangles.append(
            [self.numPoints, self.numPoints + 1, self.numPoints + 2])

        ##having already one triangle in the triangles list, we can start adding points
        ##and re-triangulate everytime we need

        #progress window > initialize before the loop
        cmds.progressWindow(
            title=
            'Creating Delaunay regions...',  #here you input your message for the progress window/can be anything
            minValue=0,
            maxValue=self.
            numPoints,  # this is imporant: when will the progress be 100%?
            status='Points left: %d' %
            self.numPoints,  # here is some status message /anything you want
            isInterruptable=True)

        #Include each point one at a time into the existing triangulations
        for i in range(len(vertex)):
            #if i is more than the original number of points, stop loop
            #cos then it is a vertex of the supertriangle, and we don't need to calculate them
            if i >= self.numPoints: break
            #get current point i coordinates
            p = vertex[i]
            #Set up the edge buffer.
            #If the point (x,y) lies inside the circumcircle formed by each triangle,
            #then the three edges of that triangle are added to the edge buffer.
            edges = []

            #create a copy of the triangles list to loop through
            tcopy = []
            tcopy.extend(triangles)
            #loop through the triangles to check the points
            for t in tcopy:
                #if the triangle is composed by the vertex in question (i), skip
                if i in t: continue
                #convert the triangle vertices to a list of coordinates
                tri = [[vertex[k][0], vertex[k][1]] for k in t]
                #check if the point i is in the circle formed by this triangle
                ic = self.inCircle(point=[p[0], p[1]], triangle=tri)
                if ic:
                    #in case ic == true:
                    #store the edges in the edges list
                    edges.append([t[0], t[1]])
                    edges.append([t[1], t[2]])
                    edges.append([t[2], t[0]])
                    #remove triangle from triangle list
                    triangles.remove(t)

            #delete all duplicate edges from the edge buffer
            #this leaves the edges of the enclosing polygon only
            edges = removeDuplicates(edges)

            #add to the triangle list all triangles formed between the point
            #and the edges of the enclosing polygon (from the edge buffer
            for j in range(len(edges)):
                v1 = edges[j][0]
                v2 = edges[j][1]
                v3 = i
                triangles.append([v1, v2, v3])

            #update progress window
            if cmds.progressWindow(query=True, isCancelled=True): break
            cmds.progressWindow(edit=True,
                                step=1,
                                status=('Points left: %d' %
                                        (self.numPoints - i)))

        #end loop for vertices

        # FINAL STEP
        # now draw the triangles defined in the triangels list

        for t in triangles:
            print(t)
            #check if this triangle does not belong to the supertriangle,
            #if it does, jump
            if t[0] > self.numPoints - 1 or t[1] > self.numPoints - 1 or t[
                    2] > self.numPoints - 1:
                continue
            #get coordinates of the triangle t
            v1 = vertex[t[0]]
            v2 = vertex[t[1]]
            v3 = vertex[t[2]]
            #see if all coordinates contain the Z value, if not, add z=0
            if len(v1) == 2: v1.append(0)
            if len(v2) == 2: v2.append(0)
            if len(v3) == 2: v3.append(0)
            #draw the curve
            crv = cmds.curve(p=[v1, v2, v3], d=1)
            crv = cmds.closeCurve(crv, rpo=1)
            #if outType is specified as "faces", draw the face
            if outType == "faces": cmds.planarSrf(crv)
            #to see in real time, uncomment the line below (increase operation time by circa 5 times)
            #cmds.refresh(cv=1)

        #end progress window
        cmds.progressWindow(endProgress=1)

        #feedback
        print("Delaunay triangulations created successfully!")
        print(">> %d points" % self.numPoints)
        print(">> %d triangles" % len(triangles))
        #check if you want to see time consumed
        if timer:
            delta_t = datetime.datetime.now() - currTime
            print(">> Time consumed: %s" % str(delta_t))
def testStaticNurbsWithOneCloseCurveTrim(self, surfacetype, abcFileName,
    trimtype):

    if (surfacetype == 0):
        ret  = MayaCmds.nurbsPlane(p=(0, 0, 0), ax=(0, 1, 0), w=1, lr=1,
            d=3, u=5, v=5, ch=0)
    elif (surfacetype == 1):
        ret  = MayaCmds.sphere(p=(0, 0, 0), ax=(0, 1, 0), ssw=0, esw=360, r=1,
            d=3, ut=0, tol=0.01, s=8, nsp=4, ch=0)
    elif (surfacetype == 2):
        ret = MayaCmds.torus(p=(0, 0, 0), ax=(0, 1, 0), ssw=0, esw=360,
            msw=360, r=1, hr=0.5, ch=0)

    name = ret[0]

    MayaCmds.curveOnSurface(name, uv=((0.170718,0.565967),
        (0.0685088,0.393034), (0.141997,0.206296), (0.95,0.230359),
        (0.36264,0.441381), (0.251243,0.569889)),
        k=(0,0,0,0.200545,0.404853,0.598957,0.598957,0.598957))
    MayaCmds.closeCurve(name+'->curve1', ch=1, ps=1, rpo=1, bb=0.5, bki=0,
        p=0.1, cos=1)

    if trimtype == 0 :
        MayaCmds.trim(name, lu=0.68, lv=0.39)
    elif 1 :
        MayaCmds.trim(name, lu=0.267062, lv=0.39475)

    degreeU = MayaCmds.getAttr(name+'.degreeU')
    degreeV = MayaCmds.getAttr(name+'.degreeV')
    spansU = MayaCmds.getAttr(name+'.spansU')
    spansV = MayaCmds.getAttr(name+'.spansV')
    formU = MayaCmds.getAttr(name+'.formU')
    formV = MayaCmds.getAttr(name+'.formV')
    minU = MayaCmds.getAttr(name+'.minValueU')
    maxU = MayaCmds.getAttr(name+'.maxValueU')
    minV = MayaCmds.getAttr(name+'.minValueV')
    maxV = MayaCmds.getAttr(name+'.maxValueV')

    surfaceInfoNode = MayaCmds.createNode('surfaceInfo')
    MayaCmds.connectAttr(name+'.worldSpace', surfaceInfoNode+'.inputSurface',
        force=True)

    controlPoints = MayaCmds.getAttr(surfaceInfoNode+'.controlPoints[*]')
    knotsU = MayaCmds.getAttr(surfaceInfoNode+'.knotsU[*]')
    knotsV = MayaCmds.getAttr(surfaceInfoNode+'.knotsV[*]')

    MayaCmds.AbcExport(j='-root %s -f %s' % (name, abcFileName))
    MayaCmds.AbcImport(abcFileName, mode='open')

    self.failUnlessEqual(degreeU, MayaCmds.getAttr(name+'.degreeU'))
    self.failUnlessEqual(degreeV, MayaCmds.getAttr(name+'.degreeV'))
    self.failUnlessEqual(spansU, MayaCmds.getAttr(name+'.spansU'))
    self.failUnlessEqual(spansV, MayaCmds.getAttr(name+'.spansV'))
    self.failUnlessEqual(minU, MayaCmds.getAttr(name+'.minValueU'))
    self.failUnlessEqual(maxU, MayaCmds.getAttr(name+'.maxValueU'))
    self.failUnlessEqual(minV, MayaCmds.getAttr(name+'.minValueV'))
    self.failUnlessEqual(maxV, MayaCmds.getAttr(name+'.maxValueV'))

    surfaceInfoNode = MayaCmds.createNode('surfaceInfo')
    MayaCmds.connectAttr(name+'.worldSpace', surfaceInfoNode+'.inputSurface',
        force=True)

    controlPoints2 = MayaCmds.getAttr( surfaceInfoNode + '.controlPoints[*]')
    self.failUnlessEqual(len(controlPoints), len(controlPoints2))
    for i in range(0, len(controlPoints)):
        cp1 = controlPoints[i]
        cp2 = controlPoints2[i]
        self.failUnlessAlmostEqual(cp1[0], cp2[0], 3, 'cp[%d].x not equal' % i)
        self.failUnlessAlmostEqual(cp1[1], cp2[1], 3, 'cp[%d].y not equal' % i)
        self.failUnlessAlmostEqual(cp1[2], cp2[2], 3, 'cp[%d].z not equal' % i)

    for i in range(0, len(knotsU)):
        ku1 = knotsU[i]
        ku2 = MayaCmds.getAttr('surfaceInfo1.knotsU[%d]' % i)
        self.failUnlessAlmostEqual(ku1, ku2, 3,
            'control knotsU # %d not equal' % i)

    for i in range(0, len(knotsV)):
        kv1 = knotsV[i]
        kv2 = MayaCmds.getAttr('surfaceInfo1.knotsV[%d]' % i)
        self.failUnlessAlmostEqual(kv1, kv2, 3,
            'control knotsV # %d not equal' % i)
Пример #25
0
 def close(self):
     """Close this curve (slow)."""
     cmds.closeCurve(self, replaceOriginal=True)
Пример #26
0
def closeCurve(*args, **kwargs):
    res = cmds.closeCurve(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res