def regularLink(rot_X, move_X, SIZE, THICK, nsTmp):
    Idx1 = 5
    Idx2 = 8

    #creates a torus
    cmds.polyTorus(sa=8, sh=8, sr=THICK, n="Link1_")
    cmds.rotate(90, 0, 0)

    #select a range of faces
    for i in range(9):
        facet = nsTmp + ":Link1_.f[" + str(Idx1) + ":" + str(Idx2) + "]"

        if i == 0:
            cmds.select(nsTmp + ":Link1_" + ".f[0]")
        else:
            cmds.select(facet, add=True)

            Idx1 = Idx1 + 8
            if i == 7:
                Idx2 = Idx2 + 7
            else:
                Idx2 = Idx2 + 8

    #extrudes the faces and moves them to the left, thus making the elongated shape
    cmds.polyExtrudeFacet(kft=True, ws=True, t=[2, 0, 0])
    cmds.delete(ch=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=2)

    cmds.select(nsTmp + ":Link1_")
    cmds.xform(cp=True)
    cmds.scale(SIZE, SIZE, SIZE)
    cmds.move(move_X, 0, 0)
    cmds.rotate(rot_X, 0, 0)
    cmds.polySmooth()
Esempio n. 2
0
def make_shape(type, name, divisions):
    """
    Creates shape based on argument passed

    Args:
        type: {cube, cone, cylinder, plane, torus, sphere}
        name: name of the object
        divisions: number of subdivisions we want to apply in x,y and z axis.
                   Same value will be taken in all axis.
    Return:
        None
    """

    if type == 'cube':
        mc.polyCube(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cone':
        mc.polyCone(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cylinder':
        mc.polyCylinder(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'plane':
        mc.polyPlane(n=name, sx=divisions, sy=divisions)
    elif type == 'torus':
        mc.polyTorus(n=name, sx=divisions, sy=divisions)
    elif type == 'sphere':
        mc.polySphere(n=name, sx=divisions, sy=divisions)
    else:
        mc.polySphere()
Esempio n. 3
0
 def createItem(self,*args):
     self.item = mc.optionMenu(self.objectSelectionMenu, query = True, value = True)        
     if self.item == "Sphere":
         self.xSubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value1= True)
         self.ySubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value2= True)
         self.radiusInput = mc.intSliderGrp(self.radiusFloat, query = True, value = True)
         mc.polySphere(n = "mySphere",sx = self.xSubInput, sy = self.ySubInput, r = self.radiusInput)
     elif self.item == "Cube":
         self.xSubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value1= True)
         self.ySubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value2= True)
         self.widthInput = mc.intSliderGrp(self.widthFloat, query = True, value = True)
         self.depthInput = mc.intSliderGrp(self.depthFloat, query = True, value = True)
         self.heightInput = mc.intSliderGrp(self.heightFloat, query = True, value = True)
         mc.polyCube(n = "myCube", sx = self.xSubInput, sy = self.ySubInput, w = self.widthInput, d = self.depthInput, h = self.heightInput)
     elif self.item == "Cylinder":
         self.xSubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value1= True)
         self.ySubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value2= True)
         self.radiusInput = mc.intSliderGrp(self.radiusFloat, query = True, value = True)
         mc.polyCylinder(n = "myCylinder",sx = self.xSubInput, sy = self.ySubInput, r = self.radiusInput)
     elif self.item == "Cone":
         self.xSubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value1= True)
         self.ySubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value2= True)
         self.radiusInput = mc.intSliderGrp(self.radiusFloat, query = True, value = True)
         mc.polyCone(n = "myCone",sx = self.xSubInput, sy = self.ySubInput, r = self.radiusInput)
     elif self.item == "Torus":
         self.xSubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value1= True)
         self.ySubInput = mc.intFieldGrp(self.objectSubFloat, query = True, value2= True)
         self.radiusInput = mc.intSliderGrp(self.radiusFloat, query = True, value = True)
         mc.polyTorus(n = "myTorus",sx = self.xSubInput, sy = self.ySubInput, r = self.radiusInput)
Esempio n. 4
0
def createCrossAxel():

    length = createMainAxel("CrossAvelWidth")
    cmds.select(cu[0])
    cmds.scale(1, 1, 1.5)
    sideCylin1 = cmds.polyCylinder(r=0.4, h=length, sz=12, sx=12, sy=12)
    cmds.rotate(90, 0, 0)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(sideCylin1[0], cu[0], op=2, n="block", ch=False)
    Tor = cmds.polyTorus(sx=2, sy=2, r=0.377, sr=0.037)
    cmds.rotate(90, 0, 0)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(Tor[0], cu[0], op=1, n="block", ch=False)
    Tor2 = cmds.polyTorus(sx=2, sy=2, r=0.377, sr=0.037)
    cmds.rotate(90, 0, 0)
    cmds.move(length / 3.2, moveZ=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(Tor2[0], cu[0], op=1, n="block", ch=False)
    Tor3 = cmds.polyTorus(sx=2, sy=2, r=0.377, sr=0.037)
    cmds.rotate(90, 0, 0)
    cmds.move(-1 * (length / 3.2), moveZ=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(Tor3[0], cu[0], op=1, n="block", ch=False)
    cmds.select(cu[0])
    cmds.rotate(0, 0, 45)
    distance1 = 0.33
    distance2 = 0.35
    createSideEdgesAxel(length, distance1, distance2)
def squareLink(rot_X, rot_Y, move_X, SIZE, THICK, nsTmp):
    cmds.polyTorus(sa=4, sr=THICK, n="Link1")
    cmds.rotate(rot_Y, rotateY=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=2)
    cmds.rotate(rot_X, rotateX=True)
    cmds.move(move_X, 0, 0)
    cmds.scale(SIZE, SIZE, SIZE)
Esempio n. 6
0
	def HI(self):
            if self.checkSphere.isChecked():
                cmds.polySphere()
            if self.checkTorus.isChecked():
                cmds.polyTorus()
            if self.checkCube.isChecked():
                cmds.polyCube()
            pass
Esempio n. 7
0
	def HI(self):
            if self.checkSphere.isChecked():
                cmds.polySphere()
            if self.checkTorus.isChecked():
                cmds.polyTorus()
            if self.checkCube.isChecked():
                cmds.polyCube()
            pass
def MyGeo(geo):
    
    if geo == "cube":
        cmds.polyCube(w=10, h=3, d=3, sx=10, sy=2, sz=2, ch=1)
    elif geo == "sphere":
        cmds.polySphere(r=1, sx=20, sy=20, ch=1)
    elif geo == "torus":
        cmds.polyTorus(r=1, sr=0.5, tw=0, sx=20, sy=20, ch=1)
Esempio n. 9
0
def RandomTorus():
    cmds.polyTorus(sx=4, sy=4, r=random.randrange(1,50), sr=random.randrange(1,50))
    cmds.select()
    Transforms()
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
    created.append(cmds.ls(selection=True))

    cmds.duplicate()
    cmds.scale(-1,1,1)
    created.append(cmds.ls())
def eightLink(rot_X, move_X, SIZE, THICK, nsTmp):
    Idx1 = 5
    Idx2 = 8

    cmds.polyTorus(sa=8, sh=8, sr=THICK, n="Link1_")
    cmds.rotate('90deg', 0, 0)

    #select a range of faces
    for i in range(9):
        facet = nsTmp + ":Link1_.f[" + str(Idx1) + ":" + str(Idx2) + "]"

        if i == 0:
            cmds.select(nsTmp + ":Link1_" + ".f[0]")
        else:
            cmds.select(facet, add=True)

            Idx1 = Idx1 + 8
            if i == 7:
                Idx2 = Idx2 + 7
            else:
                Idx2 = Idx2 + 8

    cmds.polyExtrudeFacet(kft=True, ws=True, t=[1, 0, 0])
    cmds.polyExtrudeFacet(kft=True, ws=True, t=[1, 0, 0])

    #select the vertexes and move them to make the 8 shape
    num = 44
    for i in range(7):
        if i == 0:
            cmds.select(nsTmp + ':Link1_.vtx[' + str(40) + ':' + str(41) + ']')
        else:
            cmds.select(nsTmp + ':Link1_.vtx[' + str(num) + ']', add=True)
            num += 2
    cmds.move(0, -0.8, 0, r=True)

    num = 45
    for i in range(7):
        if i == 0:
            cmds.select(nsTmp + ':Link1_.vtx[' + str(42) + ':' + str(43) + ']')
        else:
            cmds.select(nsTmp + ':Link1_.vtx[' + str(num) + ']', add=True)
            num += 2
    cmds.move(0, 0.8, 0, r=True)

    cmds.delete(ch=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=2)

    cmds.select(nsTmp + ":Link1_")
    cmds.xform(cp=True)
    cmds.scale(SIZE, SIZE, SIZE)
    cmds.move(move_X, 0, 0)
    cmds.rotate(rot_X, 0, 0)
    cmds.polySmooth()
Esempio n. 11
0
def RandomTorus():
    cmds.polyTorus(sx=4,
                   sy=4,
                   r=random.randrange(1, 50),
                   sr=random.randrange(1, 50))
    cmds.select()
    Transforms()
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
    created.append(cmds.ls(selection=True))

    cmds.duplicate()
    cmds.scale(-1, 1, 1)
    created.append(cmds.ls())
Esempio n. 12
0
def createTargetPrim(*args):
    #delete existing target primitive
    #deleteTargetPrim()

    createTargetPrim.targetprim = 0

    if UI.targetPrim == 'Cube':
        createTargetPrim.targetprim = mc.polyCube(sx=1, sy=1, sz=1)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        #if UI.randomOrientation != False:
        #mc.select(targetprim)
        mc.rotate(UI.targetOrientation[0],
                  UI.targetOrientation[1],
                  UI.targetOrientation[2],
                  a=True)

        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)
        else:
            mc.move(0, 0, 35)

    if UI.targetPrim == 'Sphere':
        mc.polySphere(sx=24, sy=24, r=1)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)

    if UI.targetPrim == 'Cylinder':
        mc.polyCylinder(sx=24, sy=2, sz=2)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)

    if UI.targetPrim == 'Torus':
        mc.polyTorus(n='target', sx=24, sy=16, r=2, sr=1)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)

    if UI.targetPrim == 'Cone':
        mc.polyCone(sx=1, sy=1, sz=1)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)
Esempio n. 13
0
    def __init__(self, index, planet_radius, number_of_rings):

        # The index is used when determining the scale and rotation of the ring.
        self.__index = index

        # To shrink each successive ring, a decrement value is calculated.
        self.__scale_decrement_value = .5 / number_of_rings

        # Names the ring.
        name = "Ring"

        # If this is the first ring created, create a polyTorus.
        if (index == 0):

            # Since this is the first ring, the outer radius is stored and used when calculating how far away the moons and starfields should be.
            radius = self.__radius = float(planet_radius + number_of_rings)

            # The torus that makes the ring is created then smoothed.
            instance_nodes = polyTorus(name=name,
                                       radius=radius,
                                       sectionRadius=(radius / 100))
            polySmooth(divisions=2)

            # Since this is the first ring, its transform node is also stored as a class member.
            self.__transform_node = instance_nodes[0]

        # Otherwise, instance the initial ring.
        else:

            # Creates an instance of the initial ring and stores the nodes.
            nodes = instance(name)

            # The transform node of the ring is stored as an instance member.
            self.__transform_node = nodes[0]
Esempio n. 14
0
def createTargetPrim(*args):
    #delete existing target primitive
    #deleteTargetPrim()

    createTargetPrim.targetprim = 0

    if UI.targetPrim == 'Cube':
        createTargetPrim.targetprim = mc.polyCube(sx=1, sy=1, sz=1)
        assignMatAndPlaceInScene(createTargetPrim.targetprim[0])

    if UI.targetPrim == 'Sphere':
        createTargetPrim.targetprim = mc.polySphere(sx=24, sy=24, r=1)
        assignMatAndPlaceInScene(createTargetPrim.targetprim[0])

    if UI.targetPrim == 'Cylinder':
        createTargetPrim.targetprim = mc.polyCylinder(sx=24, sy=2, sz=2)
        assignMatAndPlaceInScene(createTargetPrim.targetprim[0])

    if UI.targetPrim == 'Torus':
        createTargetPrim.targetprim = mc.polyTorus(n='target',
                                                   sx=24,
                                                   sy=16,
                                                   r=2,
                                                   sr=1)
        assignMatAndPlaceInScene(createTargetPrim.targetprim[0])

    if UI.targetPrim == 'Cone':
        createTargetPrim.targetprim = mc.polyCone(sx=1, sy=1, sz=1)
        assignMatAndPlaceInScene(createTargetPrim.targetprim[0])
Esempio n. 15
0
def MakeWheel(radius=3.6):  # Function returns group name for a wheel
    myListOfRotValues = range(0, 360, 20)
    wheel = []
    x = 0
    for curCyl in myListOfRotValues:
        curSpoke = mc.polyCylinder(r=0.1, h=radius)
        wheel.append(curSpoke[0])
        mc.move(0, radius / 2, 0)
        mc.move(0, 0, 0, curSpoke[0] + ".scalePivot",
                curSpoke[0] + ".rotatePivot")
        mc.rotate(20 * x, 0, 0)
        x += 1

    wheelCenter = mc.polyCylinder(ax=(1, 0, 0))
    wheel.append(wheelCenter[0])
    mc.scale(0.22, 0.6, 0.6)

    wheelEdge = mc.polyTorus(r=radius, sr=0.3, sx=40, sy=5, ax=(1, 0, 0))
    mc.scale(0.537, 1, 1)
    wheel.append(wheelEdge[0])

    finalWheel = mc.group(wheel)

    if trainSpeed > 0:
        circumference = 2 * 3.14 * radius
        wheelRotationTime = (circumference / trainSpeed)
        mc.expression(s="rotateX = time * (360 / " + str(wheelRotationTime) +
                      ");",
                      o=finalWheel)

    return finalWheel
Esempio n. 16
0
    def __init__(self, ringNumber, radius, linkRadius):

        #diffirent naming for the first ring
        if ringNumber == 0:
            (self.transform, self.shape) = cmds.polyTorus(r=radius,
                                                          sr=linkRadius,
                                                          name="Chain_root")
            self.ringName = self.transform

        #Naming for all other rings.
        else:
            (self.transform,
             self.shape) = cmds.polyTorus(r=radius,
                                          sr=linkRadius,
                                          name="ring_" + str(ringNumber))
            self.ringName = self.transform

        self.ringNumber = ringNumber
def get_geometry(geo_type='sphere', sx=8, sy=8, sz=0):

    the_primitive = 'Fancy_geo_primitive'
    output_edges = []

    if geo_type == 'sphere':
        cmds.polySphere(name=the_primitive, sx=sx, sy=sy)
        cmds.rotate(10, 0, 20, the_primitive)

    elif geo_type == 'cube':
        cmds.polyCube(name=the_primitive, sx=sx, sy=sy, sz=sz)
        cmds.rotate(30, 0, 10, the_primitive)

    elif geo_type == 'cylinder':
        cmds.polyCylinder(name=the_primitive, sx=sx, sy=sy, sz=sz)
        cmds.rotate(10, 0, 20, the_primitive)

    elif geo_type == 'cone':
        cmds.polyCone(name=the_primitive, sx=sx, sy=sy, sz=sz)
        cmds.move(0, -0.2, 0, the_primitive)
        cmds.rotate(170, 0, 10, the_primitive)

    elif geo_type == 'torus':
        cmds.polyTorus(name=the_primitive, sx=sx, sy=sy)
        cmds.rotate(30, 0, 40, the_primitive)

    elif geo_type == 'plane':
        cmds.polyPlane(name=the_primitive, sx=sx, sy=sy)
        cmds.rotate(30, 0, 45, the_primitive)

    edge_count = cmds.polyEvaluate(the_primitive)['edge']
    for i in range(edge_count):
        all_edges = cmds.polyListComponentConversion('{0}.e[{1}]'.format(
            the_primitive, i),
                                                     tv=True)
        edge_start_end = cmds.ls(all_edges, flatten=True)
        output_edges.append([
            cmds.pointPosition(edge_start_end[0]),
            cmds.pointPosition(edge_start_end[1])
        ])

    cmds.delete(the_primitive)

    return output_edges
Esempio n. 18
0
def rootZ( inBitName ):
    bit = cmds.polyTorus( axis=[0,0,1],
                            radius=6,
                            sectionRadius=0.2,
                            twist=0,
                            subdivisionsX=8,
                            subdivisionsY=3,
                            name=inBitName )
    # Return the name of the newly created bit.
    return bit[0]
def create_geometry(geo_type, sx, sy, sz=0):

    if geo_type == 'sphere':
        cmds.polySphere(sx=sx, sy=sy)

    elif geo_type == 'cube':
        cmds.polyCube(sx=sx, sy=sy, sz=sz)

    elif geo_type == 'cylinder':
        cmds.polyCylinder(sx=sx, sy=sy, sz=sz)

    elif geo_type == 'cone':
        cmds.polyCone(sx=sx, sy=sy, sz=sz)

    elif geo_type == 'torus':
        cmds.polyTorus(sx=sx, sy=sy)

    elif geo_type == 'plane':
        cmds.polyPlane(sx=sx, sy=sy)
def main():
	print "We're Running a script INSIDE MAYA!"
	print(math.sin(6))
	x = cmds.polySphere(radius=2.5)
	print x
	print cmds.polySphere(x[0], query=True, radius=True)
	cmds.polyCube()
	cmds.polyTorus()
	cmds.polySphere(radius=6.0)
	x = cmds.polySphere(radius=8.0)
	print x
	x = cmds.polySphere(radius=30.0)
	print x
	x = cmds.polySphere(radius=70.0)
	print x
	x = cmds.polySphere(radius=100.0)
	print x
	x = cmds.polySphere(radius=50.0)
	print x
Esempio n. 21
0
def rootX( inBitName ):
    # Bit is a list. [name, meshType]
    bit = cmds.polyTorus( axis=[1,0,0],
                            radius=6,
                            sectionRadius=0.2,
                            twist=0,
                            subdivisionsX=8,
                            subdivisionsY=3,
                            name=inBitName )
    # Return the name of the newly created bit.
    return bit[0]
    def __init__(self, ringNumber, radius, linkRadius):

        #diffirent naming for the first ring
        if ringNumber == 0:
            (self.transform, self.shape) = cmds.polyTorus(r=radius,
                                                          sr=linkRadius,
                                                          name="Chain_root")
            self.ringName = self.transform

            # change pivot to allow easier whole chain scaling
            # cmds.setAttr(self.transform,ax)

        #Naming for all other rings. Also parents the rings to the first ring.
        else:
            (self.transform,
             self.shape) = cmds.polyTorus(r=radius,
                                          sr=linkRadius,
                                          name="ring_" + str(ringNumber))
            self.ringName = self.transform

        self.ringNumber = ringNumber
Esempio n. 23
0
def createTire():
    global cu
    cu = cmds.polyTorus(sx=2, sy=2, r=0.5, sr=0.25)
    cmds.scale(1, 1.712, 1)
    cmds.delete(ch=True)
    middle = cmds.polyCylinder(r=0.45, h=2, sz=4, sy=12)
    cu[0] = cmds.polyBoolOp(cu[0], middle[0], op=2, n="block", ch=False)
    extrudeForTire()
    cmds.delete(ch=True)
    pip1 = cmds.polyPipe(r=0.4906, h=1.5094, t=0.0755)
    cu[0] = cmds.polyUnite(cu[0], pip1[0], n="block", ch=False)
    pip2 = cmds.polyPipe(r=0.4150, h=1.1321, t=0.0)
    cu[0] = cmds.polyUnite(cu[0], pip2[0], n="block", ch=False)
def connector():
    rgb = cmds.colorSliderGrp('miscColour', query=True, rgbValue=True)
    
    cX = 1.6
    cY = 0.6
    cZ = 0.6
    
    cMiddle = cmds.polyCylinder( h = 1.6/2, r = 0.5/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (1.6/2)/2, moveX = True )
    
    cInsideRidge = cmds.polyCylinder( h = 0.1, r = cY/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( 0.1/2, moveX = True )
    
    cOutsideRidge = cmds.polyTorus( sr = 0.05, r = (cY/2.6))
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (cX/2) - (0.08/2), moveX = True )
    
    connector = cmds.polyCBoolOp( cMiddle, cInsideRidge, op = 1 )
    connector = cmds.polyCBoolOp( connector, cOutsideRidge, op = 1 )
    
    cCut = createRoundedBlock( cY * 0.6, cY * 0.2, 5, 2 )
    cmds.move( cY + 0.1, moveX = True )
    
    connector = cmds.polyCBoolOp( connector, cCut, op = 2 )
    
    cMCut = cmds.polyCylinder( h = 1.6, r = 0.45/2, sz = 1 )
    cmds.rotate( 90, rotateZ = True )
    cmds.move( (1.6/2)/2, moveX = True )
    
    connector = cmds.polyCBoolOp( connector, cMCut, op = 2 )
    
    connectorL = cmds.duplicate( connector )
    cmds.scale( -1, scaleX = True )
    cmds.move( -(1.6/2), moveX = True )
    
    connector = cmds.polyUnite( connector, connectorL)
    
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    cmds.select( connector )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
def createParticleSystem_goal():
    # Create a constant sized particle object following a deformed torus shape (using goal)

    cmds.file(new=True, force=True)

    # Create a torus, we will use it as goal
    xrez = 14
    yrez = 8
    goalTorus = cmds.polyTorus( r=1, sr=0.5, tw=0, sx=xrez, sy=yrez, ax=(0, 1, 0), cuv=1, ch=0)[0]

    # nParticle creation depends on an optoinVar value, make sure we use the default one
    cmds.optionVar( sv=("NParticleStyle","Points") )

    # Emit a lot of particle, the actual number will be limited to the max particle attribute in the particleShape
    emitter = cmds.emitter(dx=1, dy=0, dz=0, sp=0.1, pos=(0, 5, 0),rate=2500)[0]
    particleSystem, particleSystemShape = cmds.nParticle(n="nParticle_test_goal")
    cmds.setAttr('%s.lfm' % particleSystemShape, 0) # live forever
    cmds.setAttr('%s.particleRenderType' % particleSystemShape, 7) # Blobby, to see radius
    cmds.setAttr('%s.maxCount' % particleSystemShape, xrez*yrez) # max count is the number of vertices on the torus

    cmds.connectDynamic( particleSystemShape, em=emitter)

    # Create Goal
    cmds.goal(particleSystem, w=1, utr=0, g=goalTorus);


    # Create Initial state to we start with the correct amount of particle
    # NOTE: When using this script in command line, the first frame is not correctly evaluated and the particleShape is empty
    # This doesn't happens in interactive maya
    for i in range(1, 10):
        cmds.currentTime(i)
    cmds.saveInitialState(particleSystemShape)
    cmds.currentTime(1)

    bend, bendHandle = cmds.nonLinear( goalTorus, type="bend", lowBound=-1, highBound=1, curvature=0)

    cmds.setAttr( "%s.rotateZ" % bendHandle, 90)
    cmds.setKeyframe( "%s.curvature" % bend, v=0, t=1, inTangentType="flat", outTangentType="flat")
    cmds.setKeyframe( "%s.curvature" % bend, v=-130, t=12, inTangentType="flat", outTangentType="flat")
    cmds.setKeyframe( "%s.curvature" % bend, v=130, t=24, inTangentType="flat", outTangentType="flat")

    # Make the bend animation loop
    cmds.setInfinity( bend, poi="oscillate", attribute="curvature")

    return particleSystem, particleSystemShape
Esempio n. 26
0
def createParticleSystem_goal():
    # Create a constant sized particle object following a deformed torus shape (using goal)

    cmds.file(new=True, force=True)

    # Create a torus, we will use it as goal
    xrez = 14
    yrez = 8
    goalTorus = cmds.polyTorus(r=1, sr=0.5, tw=0, sx=xrez, sy=yrez, ax=(0, 1, 0), cuv=1, ch=0)[0]

    # nParticle creation depends on an optoinVar value, make sure we use the default one
    cmds.optionVar(sv=("NParticleStyle", "Points"))

    # Emit a lot of particle, the actual number will be limited to the max particle attribute in the particleShape
    emitter = cmds.emitter(dx=1, dy=0, dz=0, sp=0.1, pos=(0, 5, 0), rate=2500)[0]
    particleSystem, particleSystemShape = cmds.nParticle(n="nParticle_test_goal")
    cmds.setAttr('%s.lfm' % particleSystemShape, 0)  # live forever
    cmds.setAttr('%s.particleRenderType' % particleSystemShape, 7)  # Blobby, to see radius
    cmds.setAttr('%s.maxCount' % particleSystemShape, xrez * yrez)  # max count is the number of vertices on the torus

    cmds.connectDynamic(particleSystemShape, em=emitter)

    # Create Goal
    cmds.goal(particleSystem, w=1, utr=0, g=goalTorus);

    # Create Initial state to we start with the correct amount of particle
    # NOTE: When using this script in command line, the first frame is not correctly evaluated and the particleShape is empty
    # This doesn't happens in interactive maya
    for i in range(1, 10):
        cmds.currentTime(i)
    cmds.saveInitialState(particleSystemShape)
    cmds.currentTime(1)

    bend, bendHandle = cmds.nonLinear(goalTorus, type="bend", lowBound=-1, highBound=1, curvature=0)

    cmds.setAttr("%s.rotateZ" % bendHandle, 90)
    cmds.setKeyframe("%s.curvature" % bend, v=0, t=1, inTangentType="flat", outTangentType="flat")
    cmds.setKeyframe("%s.curvature" % bend, v=-130, t=12, inTangentType="flat", outTangentType="flat")
    cmds.setKeyframe("%s.curvature" % bend, v=130, t=24, inTangentType="flat", outTangentType="flat")

    # Make the bend animation loop
    cmds.setInfinity(bend, poi="oscillate", attribute="curvature")

    return particleSystem, particleSystemShape
Esempio n. 27
0
def worldIgnoreSlope():
    #new file
    cmds.file(force=True, new=True)

    #move the camera
    cmds.setAttr('persp.translateX', 133.600)
    cmds.setAttr('persp.translateY', 97.700)
    cmds.setAttr('persp.translateZ', 133.600)

    #create a poly cube
    ptorus = cmds.polyTorus(r=80, sr=6, sh=15, sx=100)
    pcube = cmds.polyCube(w=0.1, h=2, d=0.1)

    #create a new MASH network
    mashNetwork = mapi.Network()
    mashNetwork.createNetwork("CurlNoiseNetwork")
    shape = cmds.listRelatives(ptorus[0], s=True)[0]
    mashNetwork.meshDistribute(shape, 1)
    cmds.setAttr(mashNetwork.distribute + '.floodMesh', 1)
    cmds.setAttr(mashNetwork.distribute + '.pointCount', 20)

    #add a World node
    node = mashNetwork.addNode("MASH_World")
    #set some attributes on the world node using the .name of the node instance
    cmds.setAttr(node.name + ".clusterMode", 7)
    cmds.setAttr(node.name + ".sparsity", 0.5)
    cmds.setKeyframe(node.name, attribute='ecosystemAge', t=['0sec'], v=0.0)
    cmds.setKeyframe(node.name, attribute='ecosystemAge', t=['5sec'], v=120.0)
    cmds.setAttr(node.name + ".ignoreSlope", 1)

    node.addGroundPlane(ptorus[0])

    jsonString = '[{"Slope": 0.6, "colorBar": [255, 255, 255], "Id Min": 0, "Name": "Default Genotype", "Seed Count": 4, "Resiliance": 0.2, "Age": 100, "Soil Quality": 0.5, "Id": 0, "Temperature": 0.5, "Rate": 0.12, "Id Max": 0, "Id Color": [0.0, 0.0, 0.0], "Moisture": 0.5, "Variance": 0.2, "Seed Age": 10, "Size": 1.0}]'  #
    cmds.setAttr(node.name + '.genotypeJSON', jsonString, type='string')

    cmds.hide(ptorus[0])
    cmds.flushIdleQueue()

    #playblast
    cmds.playbackOptions(animationEndTime='5sec')
    cmds.playblast(format="qt", viewer=True, p=100)
Esempio n. 28
0
def floatingLanterns():

    h = cmds.floatSliderGrp(height, q=True, value=True)  # radius of lantern
    r = cmds.floatSliderGrp(radius, q=True, value=True)  # height of lantern
    x = cmds.floatSliderGrp(xCenter, q=True, value=True)  # center of field
    y = cmds.floatSliderGrp(yBottom, q=True, value=True)  # bottom of field
    z = cmds.floatSliderGrp(zCenter, q=True, value=True)  # center of field
    a = cmds.floatSliderGrp(yApex, q=True,
                            value=True)  # highest floating height
    n = cmds.intSliderGrp(rowcol, q=True,
                          value=True)  # number of rows/columns of lanterns
    m = cmds.floatSliderGrp(
        dist, q=True,
        value=True)  # initial distance between vertices of cylinders
    f = cmds.intSliderGrp(frames, q=True,
                          value=True)  # number of frames in animation
    bc = cmds.colorSliderGrp(baseColor, q=True,
                             rgb=True)  # base color of lanterns

    random.seed(12345)
    cmds.select(all=True)
    cmds.delete()

    paper = cmds.polyCylinder(r=r,
                              h=h,
                              sx=50,
                              sy=1,
                              sz=1,
                              ax=(0, 1, 0),
                              rcp=0,
                              cuv=3,
                              ch=1,
                              n='myPaper')
    cmds.select(cl=True)
    for i in range(50, 100):
        cmds.select(paper[0] + '.f[' + str(i) + ']', tgl=True)
    cmds.delete()  # deletes bottom faces of cylinder for opening of lantern
    cmds.select(paper[0])
    cmds.move(0, h / 2, 0)  # moves lantern paper so that it sit on mirror

    wick = cmds.polyCube(w=0.5 * r, h=0.01 * r, d=0.5 * r, n='myWick')
    cmds.rotate(0, 45, 0)
    wickShader = cmds.shadingNode('lambert', asShader=True, n='myWickShader')
    SG1 = cmds.sets(renderable=True, noSurfaceShader=True, empty=True)
    cmds.connectAttr((wickShader + '.outColor'), (SG1 + '.surfaceShader'), f=1)
    cmds.setAttr('myWickShader.color', 0.2, 0.2, 0.2)
    cmds.setAttr('myWickShader.ambientColor', 0.2, 0.2, 0.2)
    cmds.sets(wick[0], e=1, forceElement=SG1)

    rim = cmds.polyTorus(r=r, sr=0.02 * r, sx=50)

    len = r - 0.25 * r * math.sqrt(
        2)  # length of strings = dist between rim and wick
    stringGroup = cmds.group(empty=True, name='myStringGroup')
    for i in range(0, 4):
        mv = len / 2 + 0.25 * r * math.sqrt(2)
        string = cmds.polyCylinder(r=0.01 * r, h=len, n='myString#')
        cmds.select(string[0])
        xRotate = [90, 90, 0, 0]
        zRotate = [0, 0, 90, 90]
        xMove = [0, 0, mv, -mv]
        zMove = [mv, -mv, 0, 0]
        cmds.rotate(xRotate[i], 0, zRotate[i], string)
        cmds.move(xMove[i], 0, zMove[i], string)
        cmds.parent(string, stringGroup)
    strings = cmds.polyUnite(
        rim, stringGroup,
        n='myStrings')  # unites rim and strings into one poly object
    stringShader = cmds.shadingNode('lambert',
                                    asShader=True,
                                    n='myStringShader')
    SG2 = cmds.sets(renderable=True, noSurfaceShader=True, empty=True)
    cmds.connectAttr((stringShader + '.outColor'), (SG2 + '.surfaceShader'),
                     f=1)
    cmds.setAttr('myStringShader.color', 1, 1, 1)
    cmds.setAttr('myStringShader.ambientColor', 1, 1, 1)
    cmds.sets(strings[0], e=1, forceElement=SG2)

    fire = cmds.polyUnite(
        wick, strings,
        n='myFire')  # unites wick and strings (rim + strings) into one object
    cmds.move(0, 0.01, 0, fire)  # moves fire items to sit on top of mirror

    lanternGroup = cmds.group(paper, fire, n='myLanternGroup')
    lanternInstanceGroup = cmds.group(empty=True,
                                      name='myLanternInstanceGroup')

    for i in range(0, n * n):

        instanceLanternGroup = cmds.group(empty=True,
                                          n='myLanternGroupInstance#')

        instancePaper = cmds.duplicate(paper[0], n='paperInstance#')

        # randomize color of lanterns
        r = random.uniform(bc[0] - 0.1, bc[0])
        g = random.uniform(bc[1] - 0.1, bc[1] + 0.1)
        b = random.uniform(bc[2] - 0.2, bc[2] + 0.2)

        paperShader = cmds.shadingNode('lambert',
                                       asShader=True,
                                       n='myPaperShader#')
        SG3 = cmds.sets(renderable=True, noSurfaceShader=True, empty=True)
        cmds.connectAttr((paperShader + '.outColor'), (SG3 + '.surfaceShader'),
                         f=1)
        cmds.setAttr('myPaperShader' + str(i + 1) + '.color', r, g, b)
        cmds.setAttr('myPaperShader' + str(i + 1) + '.ambientColor', r, g, b)
        cmds.sets(instancePaper[0], e=1, forceElement=SG3)
        cmds.parent(instancePaper, instanceLanternGroup)

        instanceFire = cmds.duplicate(fire, n='fireInstance#')
        cmds.parent(instanceFire, instanceLanternGroup)

        instanceLantern = cmds.polyUnite(instanceLanternGroup,
                                         n='myLanternInstance#')
        cmds.parent(instanceLantern, instanceLanternGroup)
        cmds.parent(instanceLanternGroup, lanternInstanceGroup)

        cmds.rotate(0, random.uniform(0, 360), 0, instanceLantern)

        scalingFactorXZ = random.uniform(1, 1.5)
        scalingFactorY = random.uniform(1, 1.5)
        cmds.scale(scalingFactorXZ, scalingFactorY, scalingFactorXZ,
                   instanceLantern)

        cmds.setAttr('myLanternInstance' + str(i + 1) + '.castsShadows', 0)
        cmds.setAttr('myLanternInstance' + str(i + 1) + '.receiveShadows', 0)

        # variables for placement of lanterns in rows/colums on mirror
        nf = float(n)
        mf = float(m)
        s = (nf - 1) / 2 * mf  # starting point of random placement
        xMove = float(x - s + mf * (int(i / nf)))  # determines lantern row
        zMove = float(z - s + mf * (i % nf))  # determines lantern column

        yMove = y + 0.02

        # sets lantern's floating path
        ran = random.uniform(-a / 10, a / 10)
        path = cmds.curve(p=[(xMove, yMove, zMove),
                             (xMove, yMove + a / 5, zMove),
                             (xMove + ran, yMove + 2 * a / 5, zMove + ran),
                             (xMove, yMove + 3 * a / 5, zMove),
                             (xMove - ran, yMove + 4 * a / 5, zMove - ran),
                             (xMove, yMove + a, zMove)],
                          n='myPath#')
        cmds.parent(path, instanceLanternGroup)
        cmds.select(instanceLantern, path)
        cmds.pathAnimation(fm=True,
                           f=True,
                           fa='y',
                           ua='x',
                           wut='objectrotation',
                           wu=(0, 1, 0),
                           iu=False,
                           inverseFront=False,
                           b=False,
                           stu=random.uniform(0, f / 2),
                           etu=random.uniform(f, 2 * f))
        cmds.setAttr('myPath' + str(i + 1) + '.visibility', 0)

    lantern = cmds.polyUnite(lanternGroup, n='myLantern')
    cmds.hide(lantern[0])  # hides initial lantern
    cmds.xform(instanceLanternGroup, centerPivots=True)

    mirror = cmds.polyPlane(ax=(0, 1, 0), n='myMirror')
    cmds.scale(
        n * m + m / 2, n * m + m / 2, mirror, xz=True
    )  # mirror side length = (# of lantern rows/columns)*(dist b/t lanterns)+half*(dist b/t lanterns)

    mirrorShader = cmds.shadingNode('blinn',
                                    asShader=True,
                                    name='myMirrorShader')
    cmds.setAttr('myMirrorShader.reflectivity', 1)
    cmds.setAttr('myMirrorShader.refractions', 1)
    cmds.setAttr('myMirrorShader.refractiveIndex', 5)
    SG4 = cmds.sets(renderable=True, noSurfaceShader=True, empty=True)
    cmds.connectAttr((mirrorShader + '.outColor'), (SG4 + '.surfaceShader'),
                     f=1)
    cmds.sets(mirror[0], e=1, forceElement=SG4)
    cmds.setAttr('myMirror.castsShadows', 0)
    cmds.setAttr('myMirror.receiveShadows', 0)

    cmds.select(cl=True)
Esempio n. 29
0
 def _polyTorus(self):
     cmds.polyTorus()
def PolyToruses(\
x = random.uniform(-10,10),\
x_r = 1,\
y = random.uniform(0,20),\
y_r = 1,\
z = random.uniform(-10,10),\
z_r = 1,\
xRot = random.uniform( 0, 360 ),\
xRot_r = 10,\
yRot = random.uniform( 0, 360 ),\
yRot_r = 10,\
zRot = random.uniform( 0, 360 ),\
zRot_r = 10,\
r = random.uniform(0,2),\
r_r = .1,\
g = random.uniform(0,2),\
g_r = .1,\
b = random.randint(0,2),\
b_r = .1,\
scaleF = random.uniform( 0.3, 1.5 ),\
scaleF_r = .1,\
):
    
    def change(start,min,max,rate):
    	if random.randint(0,5) == 0:
    		rate = (-1 * rate)
    	start += rate
    	if start < min or start > max:
    		rate = (-1 * rate)
    		start += rate
    	return start,rate
    
  
    for i in range( 0, 50 ):
       
       #create cube
    	cmds.polyTorus( sx=1, sy=1, r=1, sr=1, n='torus{}'.format(i))
    	
    	#vary location
    	x = change(x,-10,10,x_r)[0]
    	x_r = change(x,-10,10,x_r)[1]
    	y = change(y,0,20,y_r)[0]
    	y_r = change(y,0,20,y_r)[1]
    	z = change(z,-10,10,z_r)[0]
    	z_r = change(z,-10,10,z_r)[1]
    	
    	#vary rotation
    	xRot = change(xRot,1,360,xRot_r)[0]
    	xRot_r = change(xRot,1,360,xRot_r)[1]
    	yRot = change(yRot,1,360,yRot_r)[0]
    	yRot_r = change(yRot,1,360,yRot_r)[1]
    	zRot = change(zRot,1,360,zRot_r)[0]
    	zRot_r = change(zRot,1,360,zRot_r)[1]
    	
    	#vary color
    	r = change(r,0,2,r_r)[0]
    	r_r = change(r,0,2,r_r)[1]
    	g = change(g,0,2,g_r)[0]
    	g_r = change(g,0,2,g_r)[1]
    	b = change(b,0,2,b_r)[0]
    	b_r = change(b,0,2,b_r)[1]
    	
    	#vary scale
    	scaleF = change(scaleF,0.3,1.5,scaleF_r)[0]
    	scaleF_r = change(scaleF,0.3,1.5,scaleF_r)[1]
    	
    	#apply variabels
    	cmds.rotate( xRot, yRot, zRot, 'torus{}'.format(i))
    	
    	cmds.scale(scaleF, scaleF, scaleF, 'torus{}'.format(i))
    	
    	cmds.move( x, y, z, 'torus{}'.format(i))
    	
    	cmds.sets( name='TorusMaterial{}'.format(i), renderable=True, empty=True )
    	cmds.shadingNode( 'phong', name='TorusShader{}'.format(i), asShader=True )
    	cmds.setAttr( 'TorusShader{}'.format(i)+'.color', r, g, b, type='double3' )
    	cmds.surfaceShaderList( 'TorusShader{}'.format(i), add='TorusMaterial{}'.format(i))
    	cmds.sets( 'torus{}'.format(i), forceElement='TorusMaterial{}'.format(i))
Esempio n. 31
0
def MakeCar():
    trainCarTop = []

    carBody = mc.polyCube()
    trainCarTop.append(carBody[0])
    mc.scale(1.6, 12, 10)

    for x in range(0, 22):
        mc.polyExtrudeFacet(carBody[0] + ".f[4]", thickness=1.6)

    x = 0
    for x in range(0, 12):
        if x == 0:
            faceNum = 0
        else:
            faceNum = 8 * x + 5
        faceString = ".f[" + str(faceNum) + "]"
        mc.polyExtrudeFacet(carBody[0] + faceString, thickness=0.5)
        x += 1

    x = 0
    for x in range(0, 12):
        if x == 0:
            faceNum = 2
        else:
            faceNum = 8 * x + 3
        faceString = ".f[" + str(faceNum) + "]"
        mc.polyExtrudeFacet(carBody[0] + faceString, thickness=0.5)
        x += 1

    mc.select(carBody[0])
    mc.move(-80, 11, 0)

    bottomRail = mc.polyCube()
    trainCarTop.append(bottomRail[0])
    mc.move(-62.27, 3.691, 0)
    mc.scale(40.221, 1.036, 3.53)

    connectorBack = mc.polyTorus(r=1.212, sr=0.25)
    trainCarTop.append(connectorBack[0])
    mc.move(-82.834, 3.71, 0)

    connectorFront = mc.polyTorus(r=1.212, sr=0.25)
    trainCarTop.append(connectorFront[0])
    mc.move(-41.979, 3.71, 0)
    mc.rotate(90, 0, 0)

    theFrikinMain = mc.group(trainCarTop)

    # Wheels on the cars

    carWheels = []
    whe01 = MakeWheel(radius=2.5)
    mc.move(-49.672, 3.78, 3.14)
    mc.rotate(0, 90, 0)
    carWheels.append(whe01)

    whe02 = mc.duplicate(rr=True, ic=True)
    carWheels.extend(whe02)
    mc.move(-55.4, 3.78, 3.14)

    whe03 = mc.duplicate(rr=True, ic=True)
    carWheels.extend(whe03)
    mc.move(-70.123, 3.78, 3.14)

    whe04 = mc.duplicate(rr=True, ic=True)
    carWheels.extend(whe04)
    mc.move(-75.727, 3.78, 3.14)

    wheelsRight = mc.group(carWheels)

    wheelsLeft = mc.duplicate(rr=True, ic=True)
    mc.move(0, 0, -6.245)

    # Group all geometry in car

    theCar = []
    theCar.append(theFrikinMain)
    theCar.append(wheelsRight)
    theCar.extend(wheelsLeft)
    groupedCar = mc.group(theCar, n="Car1")
    mc.move(0,
            -8.978713,
            0,
            groupedCar + '.scalePivot',
            groupedCar + '.rotatePivot',
            r=True)

    return groupedCar
def circleLink(rot_X, move_X, SIZE, THICK, nsTmp):
    cmds.polyTorus(sr=THICK, n="Link1")
    cmds.move(move_X, 0, 0)
    cmds.rotate(rot_X, 0, 0)
    cmds.scale(SIZE, SIZE, SIZE)
Esempio n. 33
0
import maya.cmds as mc

plane = mc.polyPlane(n="BasicPlane", w=25, h=25)

torus = mc.polyTorus(n="Torus")

mc.move(0, 5, 0, torus)
mc.scale(5, 5, 5, torus)

mc.createNode('transform', n='RPRPhysicalLightTop')
phLightTop = mc.createNode('RPRPhysicalLight',
                           n='RPRPhysicalLightShapeTop',
                           p='RPRPhysicalLightTop')

mc.move(0, 24, 0, phLightTop)
mc.rotate(-90, 0, 0, phLightTop)
mc.scale(5, 5, 1, phLightTop)

mc.setAttr('RPRPhysicalLightShapeTop.lightType', 3)
mc.setAttr('RPRPhysicalLightShapeTop.lightIntensity', 1.5)

mc.createNode('transform', n='RPRPhysicalLightBottom')
phLightBottom = mc.createNode('RPRPhysicalLight',
                              n='RPRPhysicalLightShapeBottom',
                              p='RPRPhysicalLightBottom')

mc.move(0, 2, 0, phLightBottom)
mc.rotate(90, 0, 0, phLightBottom)
mc.scale(5, 5, 1, phLightBottom)
Esempio n. 34
0
def makeTube():
    """
    makes a simple tube mesh
    """
    mesh = cmds.polyTorus(r=2, sr=0.2,  sx=50, sy=4, tw=45)
    cmds.setAttr(mesh[0]+'.sy', 5)
Esempio n. 35
0
def run_script(num_shield_pieces=50):
    RED = [1, 0, 0]  #red blood cells
    BLUE = [0, 0, 1]  #blue for the core, aka Sonic
    DARK_RED = [.545, 0, 0]

    #create the lighting for the scene
    main_light = cmds.directionalLight(name="main_light", intensity=5)
    cmds.move(-5.711, 14.564, 11.097, "main_light")
    cmds.rotate('-67.367deg', '-24.33deg', '54.557deg', "main_light")

    #create the shape of the core and the shield
    shield_shape = cmds.polyTorus(sr=0.2, name="myRing#")  #shape of shield
    shield_center = cmds.polyPlatonicSolid(radius=2.55, st=1, name="core")
    applyMaterial(shield_center[0], DARK_RED, 'lambert')
    cmds.move(0, 9, 0, "core")  #move the core higher

    #add decorative cylinder to core
    core_piece_1 = cmds.polyCylinder(name="tube_1")
    applyMaterial(core_piece_1[0], BLUE, 'lambert')
    cmds.move(0.195, 11.014, -1.221, "tube_1")
    cmds.rotate('-30.351deg', 0, 0, "tube_1")
    cmds.scale(0.505, 0.619, 0.505, "tube_1")

    #add another decorative cylinder to core
    core_piece_2 = cmds.polyCylinder(name="tube_2")
    applyMaterial(core_piece_2[0], RED, 'lambert')
    cmds.move(-0.917, 11.185, -0.216, "tube_2")
    cmds.rotate('-3.436deg', '14.201deg', '24.834deg', "tube_2")
    cmds.scale(0.505, 0.619, 0.505, "tube_2")

    #generate random shield fragments
    shield_pieces, shield_pieces_group = generate_shield(
        shield_shape, num_shield_pieces)

    #coloring the shield pieces
    for piece_obj in shield_pieces:
        applyMaterial(piece_obj[0], RED, 'phong')

    #aim fragments at core
    aim_at_first(shield_center, shield_pieces)

    #create and link expansion attribute
    locator_group = expand_from_first(shield_center, shield_pieces)

    #must group locators so they can be rotated with the fragments
    cmds.parent(locator_group, shield_pieces_group)

    startTime = cmds.playbackOptions(query=True, minTime=True)
    endTime = cmds.playbackOptions(query=True, maxTime=True)

    #second param is rotation param
    key_rotation(shield_pieces_group, 'rotateY', startTime, endTime)

    #create heartbeat animation pattern
    cmds.cutKey(shield_center,
                time=(startTime, endTime),
                attribute='expansion')
    heartbeat(shield_center, 0)
    heartbeat(shield_center, 2)
    heartbeat(shield_center, 4)
    heartbeat(shield_center, 6)
    heartbeat(shield_center, 8)
    heartbeat(shield_center, 10)
    cmds.selectKey(shield_center,
                   time=(startTime, endTime),
                   attribute='expansion',
                   keyframe=True)
    cmds.keyTangent(inTangentType='linear', outTangentType='linear')
Esempio n. 36
0
 def _polyTorus(self):
     cmds.polyTorus()
    def testAnimPolyDeleteReload(self):

        # create a poly cube and animate
        shapeName = 'pCube'
        MayaCmds.polyCube( name=shapeName )
        MayaCmds.move(5, 0, 0, r=True)
        MayaCmds.setKeyframe( shapeName+'.vtx[2:5]', time=[1, 24] )
        MayaCmds.currentTime( 12 )
        MayaCmds.select( shapeName+'.vtx[2:5]',replace=True )
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe( shapeName+'.vtx[2:5]', time=[12] )

        # create a poly sphere and animate
        shapeName = 'pSphere'
        MayaCmds.polySphere( name=shapeName )
        MayaCmds.move(-5, 0, 0, r=True)
        MayaCmds.setKeyframe( shapeName+'.vtx[200:379]',
            shapeName+'.vtx[381]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select( shapeName+'.vtx[200:379]',
            shapeName+'.vtx[381]',replace=True)
        MayaCmds.scale(0.5, 0.5, 0.5, relative=True)
        MayaCmds.setKeyframe( shapeName+'.vtx[200:379]',
            shapeName+'.vtx[381]', time=[12])
        MayaCmds.currentTime(1)

        # create a poly torus and animate
        shapeName = 'pTorus'
        MayaCmds.polyTorus(name=shapeName)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:219]',time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[200:219]',replace=True)
        MayaCmds.scale(2, 1, 2, relative=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:219]', time=[12])

        # create a poly cone and animate
        shapeName = 'pCone'
        MayaCmds.polyCone(name=shapeName)
        MayaCmds.move(0, 0, -5, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[20]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[20]',replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[20]', time=[12])

        # write it out to Abc file and load back in
        self.__files.append(util.expandFileName('testPolyReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root pCube -root pSphere -root pTorus -root pCone -file %s' %
            self.__files[-1])

        # load back the Abc file, delete the sphere and save to a maya file
        MayaCmds.AbcImport( self.__files[-1], mode='open')
        MayaCmds.delete('pSphere')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('pCube', 'pTorus', 'pCone', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        shapeList = MayaCmds.ls(type='mesh')
        self.failUnlessEqual(len(shapeList), 7)

        meshes = [('|pCube|pCubeShape', '|ReloadGrp|pCube|pCubeShape'),
            ('|pTorus|pTorusShape', '|ReloadGrp|pTorus|pTorusShape'),
            ('|pCone|pConeShape', '|ReloadGrp|pCone|pConeShape')]
        for m in meshes:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareMesh(m[0], m[1]):
                    self.fail('%s and %s are not the same at frame %d' %
                        (m[0], m[1], t))
Esempio n. 38
0
cube = mc.polyCube (w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 1, 0), cuv=4, ch=1)
mc.scale(2, 2.6, 3, cube, r=True)
mc.move(-6, 0, 0, cube, r=True)
mc.rotate(14, 4, 3.5, cube, os=True)

cylinder = mc.polyCylinder(r=1, h=2, sx=20, sy=1, sz=1, ax=(0, 1, 0), rcp=0, cuv=3, ch=1)
mc.scale(2, 1, 2, cylinder, r=True)
mc.move(0, 0, -6, r=True)
mc.rotate(3, 5, 6, cylinder, r=True, os=True)

cone = mc.polyCone(r=1, h=2, sx=20, sy=1, sz=0, ax=(0, 1, 0), rcp=0, cuv=3, ch=1)
mc.scale(2, 3, 2, cone, r=True)
mc.move(6, 0, 6, cone, r=True)
mc.rotate(12, 11, 5, cone, r=True, os=True)

torus = mc.polyTorus(r=1, sr=0.5, tx=0, sx=20, sy=0, ax=(0, 1, 0), cuv=3, ch=1)
mc.scale(2, 2, 2, torus, r=True)
mc.move(-6, 0, 6, torus, r=True)
mc.rotate(1, 23, 5, torus, r=True, os=True)

prism = mc.polyPrism(w=1, ns=3, sh=1, sc=0, ax=(0, 1, 0), cuv=3, ch=1)
mc.scale(2, 2, 2, prism, r=True)
mc.move(0, 0, 6, prism, r=True)
mc.rotate(1, 4, 30, prism, r=True, os=True)

pyramid = mc.polyPyramid(w=1, ns=4, sh=0, sc=0, ax=(0, 1, 0), cuv=3, ch=1)
mc.scale(4, 5, 4, pyramid, r=True)
mc.move(6, 0, -6, pyramid, r=True)

pipe = mc.polyPipe(r=1, h=3, t=0.5, sa=20, sh=1, sc=0, ax=(0, 1, 0), cuv=3, rcp=0, ch=1)
mc.scale(2, 2, 2, pipe, r=True)
Esempio n. 39
0
def torus(**kwargs):

    try:
        return cmds.polyTorus(**kwargs)[1]
    except:
        raise
Esempio n. 40
0
def polyTorus(*args, **kwargs):
    res = cmds.polyTorus(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Esempio n. 41
0
    def testAnimPolyDeleteReload(self):

        # create a poly cube and animate
        shapeName = 'pCube'
        MayaCmds.polyCube(name=shapeName)
        MayaCmds.move(5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[2:5]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[2:5]', replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[2:5]', time=[12])

        # create a poly sphere and animate
        shapeName = 'pSphere'
        MayaCmds.polySphere(name=shapeName)
        MayaCmds.move(-5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:379]',
            shapeName + '.vtx[381]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[200:379]',
            shapeName + '.vtx[381]', replace=True)
        MayaCmds.scale(0.5, 0.5, 0.5, relative=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:379]',
            shapeName + '.vtx[381]', time=[12])
        MayaCmds.currentTime(1)

        # create a poly torus and animate
        shapeName = 'pTorus'
        MayaCmds.polyTorus(name=shapeName)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:219]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[200:219]', replace=True)
        MayaCmds.scale(2, 1, 2, relative=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:219]', time=[12])

        # create a poly cone and animate
        shapeName = 'pCone'
        MayaCmds.polyCone(name=shapeName)
        MayaCmds.move(0, 0, -5, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[20]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[20]', replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[20]', time=[12])

        # write it out to Abc file and load back in
        self.__files.append(util.expandFileName('testPolyReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root pCube -root pSphere -root pTorus -root pCone -file %s' % 
            self.__files[-1])

        # load back the Abc file, delete the sphere and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')
        MayaCmds.delete('pSphere')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('pCube', 'pTorus', 'pCone', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        shapeList = MayaCmds.ls(type='mesh')
        self.failUnlessEqual(len(shapeList), 7)

        meshes = [('|pCube|pCubeShape', '|ReloadGrp|pCube|pCubeShape'),
            ('|pTorus|pTorusShape', '|ReloadGrp|pTorus|pTorusShape'),
            ('|pCone|pConeShape', '|ReloadGrp|pCone|pConeShape')]
        for m in meshes:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareMesh(m[0], m[1]):
                    self.fail('%s and %s are not the same at frame %d' % 
                        (m[0], m[1], t))
Esempio n. 42
0
import maya.cmds as cmds

#create generic polycube (automatically selects it)
cmds.polyCube(sx=10, sy=10, sz=10, w=20, h=20, d=20, n="generic_cube")
#create generic polytorus (automatically selects it)
cmds.polyTorus(sx=8, sy=16, r=10, sr=1, n="generic_torus")
#delete selected object
cmds.delete()
Esempio n. 43
0
    def testAnimSubDDeleteReload(self):

        # create a subD cube and animate
        shapeName = 'cube'
        MayaCmds.polyCube(name=shapeName)
        MayaCmds.select('cubeShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[2:5]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[2:5]', replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[2:5]', time=[12])

        # create a subD sphere and animate
        shapeName = 'sphere'
        MayaCmds.polySphere(name=shapeName)
        MayaCmds.select('sphereShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(-5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:379]', shapeName + '.vtx[381]',
            time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[200:379]', shapeName + '.vtx[381]',
            replace=True)
        MayaCmds.scale(0.5, 0.5, 0.5, relative=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:379]', shapeName + '.vtx[381]',
            time=[12])
        MayaCmds.currentTime(1)

        # create a subD torus and animate
        shapeName = 'torus'
        MayaCmds.polyTorus(name=shapeName)
        MayaCmds.select('torusShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:219]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[200:219]', replace=True)
        MayaCmds.scale(2, 1, 2, relative=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[200:219]', time=[12])

        # create a subD cone and animate
        shapeName = 'cone'
        MayaCmds.polyCone(name=shapeName)
        MayaCmds.select('coneShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(0, 0, -5, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[20]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName + '.vtx[20]', replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName + '.vtx[20]', time=[12])

        self.__files.append(util.expandFileName('testSubDReload.abc'))

        # write it out to Abc file and load back in
        MayaCmds.AbcExport(j='-fr 1 24 -root cube -root sphere -root torus -root cone -file ' + 
            self.__files[-1])

        # load back the Abc file, delete the sphere and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')
        MayaCmds.delete('sphere')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('cube', 'torus', 'cone', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        shapeList = MayaCmds.ls(type='mesh')
        self.failUnlessEqual(len(shapeList), 7)

        # test the equality of cubes
        meshes = [('|cube|cubeShape', '|ReloadGrp|cube|cubeShape'),
            ('|torus|torusShape', '|ReloadGrp|torus|torusShape'),
            ('|cone|coneShape', '|ReloadGrp|cone|coneShape')]

        for m in meshes:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareMesh(m[0], m[1]):
                    self.fail('%s and %s are not the same at frame %d' % 
                        (m[0], m[1], t))
def rim():
    
    #get values from UI
    rimStyle = cmds.radioButtonGrp( 'rimStyle', query = True, select = True)
    rgb = cmds.colorSliderGrp('wheelColour', query=True, rgbValue=True)
    
    #set up variables
    radius = 1.6
    widthHalf = 2.1 / 2
    
    if( rimStyle == 1 ):
        mediumCircle = cmds.polyCylinder( h = widthHalf * 0.4, r = radius * 0.67 )
        cmds.rotate( 90, rotateZ = True )
        
        crossV = cmds.polyCube( w = widthHalf, h = 0.4, d = 0.2 )
        crossH = cmds.polyCube( w = widthHalf, h = 0.2, d = 0.4 )
        cross = cmds.polyCBoolOp( crossV, crossH, op = 1 )
        cmds.move( widthHalf / 2, moveX = True ) 
        mediumCircle = cmds.polyCBoolOp( mediumCircle, cross, op = 2 )
        
        innerCircle = cmds.polyPipe( h = widthHalf * 0.3, r = radius * 0.33, t = 0.14 )    
        cmds.rotate( 90, rotateZ = True )
        cmds.move( ((widthHalf * 0.4) / 2) + ((widthHalf * 0.3) / 2), moveX = True )
        
        outerCircle = cmds.polyPipe( h = widthHalf, r = radius, t = 0.2 )
        cmds.rotate( 90, rotateZ = True )
        cmds.move( (((widthHalf * 0.4) / 2) + ((widthHalf * 0.5) / 2)) + 0.1, moveX = True )
        
        outerCircleCut = cmds.polyPipe( h = widthHalf * 0.33, r = radius, t = 0.1 )
        cmds.rotate( 90, rotateZ = True )
        cmds.move( (((widthHalf * 0.4) / 2) + ((widthHalf * 0.5) / 2)) + 0.1, moveX = True )
        
        outerCircle = cmds.polyCBoolOp( outerCircle, outerCircleCut, op = 2 )
        
        slope = cmds.polyCone()
        cmds.rotate( 90, rotateZ = True )
        cmds.move( 0.810, moveX = True )
        cmds.scale( 5.455, 1, 5.455 )
        
        slopeCutL = cmds.polyCylinder( h = widthHalf, r = radius )
        cmds.rotate( 90, rotateZ = True )
        cmds.move( -( widthHalf / 2), moveX = True )
        
        slopeCutR = cmds.polyCylinder( h = 4, r = radius * 10 )
        cmds.rotate( 90, rotateZ = True )
        cmds.move( 2.326, moveX = True )
        
        slope = cmds.polyCBoolOp( slope, slopeCutL, op = 2 )[0]
        slope = cmds.polyCBoolOp( slope, slopeCutR, op = 2 )[0]
        
        cmds.delete( slope+".f[21]")
        
        rimL = cmds.polyUnite( mediumCircle, innerCircle, outerCircle, slope )
        cmds.move( (widthHalf*0.4)/2, moveX = True )
        
        rimR = cmds.duplicate( rimL )
        cmds.scale( -1, scaleX = True )
        cmds.move( -((widthHalf*0.4)/2), moveX = True )
        
        rim = cmds.polyUnite( rimR, rimL )
    
    elif( rimStyle == 2 ):
        
        radius  = 1.5
        circleList = []
        
        mainCircle = cmds.polyCylinder( h = 0.4, r = radius - 0.2 )
        innerCircle = cmds.polyCylinder( h = 0.5, r = radius * 0.2 )
        hCross = cmds.polyCube( w = radius * 0.24, h = 3, d = radius * 0.1 )
        vCross = cmds.polyCube( w = radius * 0.1, h = 3, d = radius * 0.24 )
        cross = cmds.polyCBoolOp( hCross, vCross, op = 1 )[0]
        
        rim = cmds.polyCBoolOp( mainCircle, innerCircle, op = 1 )
        rim = cmds.polyCBoolOp( rim, cross, op = 2 )
        
        lRidge = cmds.polyTorus( sr = 0.1, r = (radius * 0.9))
        cmds.move( 0.4/2, moveY = True )
        rRidge = cmds.polyTorus( sr = 0.1, r = (radius * 0.9))
        cmds.move( -(0.4/2), moveY = True )
        
        rim = cmds.polyCBoolOp( rim, lRidge, op = 1 )[0]
        rim = cmds.polyCBoolOp( rim, rRidge, op = 1 )[0]
        
        cutCircle = cmds.polyCylinder( h = 3, r = radius * 0.17 )[0]
        
        cmds.move( 0, 0, 0.8)
    
        cmds.move( 0, 0, 0, cutCircle+".scalePivot", cutCircle+".rotatePivot", absolute=True)
        
        circleList.append( cutCircle )
        
        for i in range( 0, 5):
            cutCircle = cmds.duplicate( cutCircle )
            cmds.rotate( 0, 60, 0, cutCircle, r = True )
            circleList.append( cutCircle )
    
        
        cutCircles = cmds.polyUnite( *circleList)
        
        rim = cmds.polyCBoolOp( rim, cutCircles, op = 2 )
        
        cmds.rotate( 90, rotateX = True )
        
            
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    cmds.select( rim )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
    def testAnimSubDDeleteReload(self):

        # create a subD cube and animate
        shapeName = 'cube'
        MayaCmds.polyCube( name=shapeName )
        MayaCmds.select('cubeShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[2:5]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[2:5]',replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[2:5]', time=[12])

        # create a subD sphere and animate
        shapeName = 'sphere'
        MayaCmds.polySphere(name=shapeName)
        MayaCmds.select('sphereShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(-5, 0, 0, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:379]', shapeName+'.vtx[381]',
            time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[200:379]',  shapeName+'.vtx[381]',
            replace=True)
        MayaCmds.scale(0.5, 0.5, 0.5, relative=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:379]',  shapeName+'.vtx[381]',
            time=[12])
        MayaCmds.currentTime(1)

        # create a subD torus and animate
        shapeName = 'torus'
        MayaCmds.polyTorus(name=shapeName)
        MayaCmds.select('torusShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:219]',time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[200:219]',replace=True)
        MayaCmds.scale(2, 1, 2, relative=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[200:219]', time=[12])

        # create a subD cone and animate
        shapeName = 'cone'
        MayaCmds.polyCone( name=shapeName )
        MayaCmds.select('coneShape')
        MayaCmds.addAttr(longName='SubDivisionMesh', attributeType='bool',
            defaultValue=True)
        MayaCmds.move(0, 0, -5, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[20]', time=[1, 24])
        MayaCmds.currentTime(12)
        MayaCmds.select(shapeName+'.vtx[20]',replace=True)
        MayaCmds.move(0, 4, 0, r=True)
        MayaCmds.setKeyframe(shapeName+'.vtx[20]', time=[12])

        self.__files.append(util.expandFileName('testSubDReload.abc'))

        # write it out to Abc file and load back in
        MayaCmds.AbcExport(j='-fr 1 24 -root cube -root sphere -root torus -root cone -file ' +
            self.__files[-1])

        # load back the Abc file, delete the sphere and save to a maya file
        MayaCmds.AbcImport( self.__files[-1], mode='open' )
        MayaCmds.delete('sphere')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('cube', 'torus', 'cone', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        shapeList = MayaCmds.ls(type='mesh')
        self.failUnlessEqual(len(shapeList), 7)

        # test the equality of cubes
        meshes = [('|cube|cubeShape', '|ReloadGrp|cube|cubeShape'),
            ('|torus|torusShape', '|ReloadGrp|torus|torusShape'),
            ('|cone|coneShape', '|ReloadGrp|cone|coneShape')]

        for m in meshes:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareMesh(m[0], m[1]):
                    self.fail('%s and %s are not the same at frame %d' %
                        (m[0], m[1], t))
Esempio n. 46
0
 def kmTorus(self):
     mc.polyTorus(r=6, sr=3, tw=0, sx=8, sy=8, ax=[0, 1, 0], cuv=1, ch=1)
def octLink(rot_X, move_X, SIZE, THICK, nsTmp):
    cmds.polyTorus(sa=8, sh=8, sr=THICK, n="Link1")
    cmds.move(move_X, 0, 0)
    cmds.rotate(rot_X, 0, 0)
    cmds.scale(SIZE, SIZE, SIZE)