示例#1
0
def changeTeeth(constructor, extrude, teeth=10, length=0.3):
    """
    Change the number of teeth on a gear with a given number of teeth and a given length for the teeth.
    This will create a new extrude node.
    Args:
        constructor (str): the constructor node
        extrude (str): the extrude node
        teeth (int): the number of teeth to create
        length (float): the length of the teeth to create
    """
    spans = teeth * 2

    # Tmodify its attributes instead of creating a new one
    cmds.polyPipe(constructor, edit=True, subdivisionsAxis=spans)

    # list of faces to extrude as teeth
    sideFaces = range(spans * 2, spans * 3, 2)
    faceNames = []

    for face in sideFaces:
        faceName = 'f[%s]' % (face)
        faceNames.append(faceName)

    #   cmds.setAttr('extrudeNode.inputComponents', numberOfItems, item1, item2, item3, type='componentList')
    cmds.setAttr('%s.inputComponents' % (extrude),
                 len(faceNames),
                 *faceNames,
                 type="componentList")

    # cmds.setAttr('extrudeNode.inputComponents', 2, 'f[1]', 'f[2]', type='componentList'

    cmds.polyExtrudeFacet(extrude, edit=True, ltz=length)
示例#2
0
def update_gear(constructor, extrude, teeth=10, length=0.3):
    """
    Updates created gear object with new values
    :param constructor: gear object
    :param extrude: list of extruded faces
    :param teeth: new number of teeth
    :param length: new length of teeth
    :return: void
    """
    spans = spans_count(teeth)
    side_faces = create_side_faces(spans)

    cmds.polyPipe(constructor, subdivisionsAxis=spans, edit=True)

    face_names = []

    for face in side_faces:
        face_name = "f[{}]".format(face)
        face_names.append(face_name)

    cmds.setAttr("{}.inputComponents".format(extrude),
                 len(face_names),
                 *face_names,
                 type="componentList")

    cmds.polyExtrudeFacet(extrude, edit=True, ltz=length)
 def __init__(self, name_, height, radius, sides, thickness, shader):
     '''
     Initializes a PipeHouse object, and creates a polygonal house object based on a
     pipe primitive.
     
     self: Object that is to be initialized.
     name_: A string with the name the polygonal house object will have.
     height: The height of the house.
     radius: See Attributes.
     sides: See Attributes.
     thickness: See Attributes.
     shader: Shader that will be assigned to the house. 
     On exit: A PipeHouse object has been initialized and a polygonal house has 
              been created out of a pipe primitive. A foundation for the house has
              also been created and united with the box. The given shader has been 
              assigned to the house. 
     '''
     House.__init__(self, name_, "pipe", height, radius * 2, radius * 2)
     self.radius = radius
     self.sides = sides
     self.thickness = thickness
     # The actual height of a pipe object in maya is half of the height it is given. Therefore here h = 2 * height.
     n = cmds.polyPipe(n = name_, r = radius, h = 2 * height, t = thickness, sa = sides, sh = height)
     cmds.xform(n[0], translation = (0,height/2.0,0))
     f = cmds.polyPipe(n = "foundation", r = radius + 0.15, height = 0.8 * 2, t = thickness + 0.3, sa = sides)
     cmds.xform(f[0], translation = (0, 0.4, 0))
     n = cmds.polyUnite(n[0],f[0], n = name_)
     self.name = n[0]
     cmds.sets(n[0], edit=True, forceElement=shader[1])
     cmds.delete(self.name, ch = True)
示例#4
0
 def createStalk(self):
     ''' This method creates the stalk. '''
     
     # y ax is calculated by flower position
     mc.polyPipe( subdivisionsHeight=3 );
     mc.scale( 0.24, self.flowerTY+1, 0.24 )
     mc.move( 0, -self.flowerTY/2, 0 );
     mc.displaySmoothness( divisionsU=3, divisionsV=3, pointsWire=16, pointsShaded=4, polygonObject=3 );
     self.currentStalk = mc.ls( sl=True );
     currentStalk0 = self.currentStalk[0]
      
     # bend the stalk
     bendStalkRandomUpX = 1.5 * (1.0 - random.random())
     bendStalkRandomUpZ = 1.5 * (1.0 - random.random())
     for uCV in range (40,60):    
         mc.select( currentStalk0 + ".vtx[" + str(uCV) + "]" );
         mc.move( bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True );
         mc.select( currentStalk0 + ".vtx[" + str(uCV+60) + "]" );
         mc.move( bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True );
     
     bendStalkRandomDownX = 1.2 * (1.0 - random.random())
     bendStalkRandomDownZ = 1.2 * (1.0 - random.random())
     for uCV in range (20,40):
         mc.select( currentStalk0 + ".vtx[" + str(uCV) + "]" );
         mc.move( bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True );
         mc.select( currentStalk0 + ".vtx[" + str(uCV+100) + "]" );
         mc.move( bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True )
     
     # delete history
     mc.select( currentStalk0 )
     maya.mel.eval( "DeleteHistory" )
     
     mc.select( clear=True )
     
     return self.currentStalk
    def changeTeeth(self, teeth=10, length=0.3):
        """
        this function is used to change the number of teeth and its length
        Args:
            teeth: give the NEW number of teeth
            length: give the NEW length of teeth

        Returns:
            self.transform
            self.constructor
            self.extrude

        """

        # todo   if not extrude, constructor:
        #    raise RuntimeError(" either constructor or extrude node is deleted, maybe you have deleted construction history")

        # new number of  faces (spans)= teeth*2
        spans = teeth * 2

        # edit the gear
        cmds.polyPipe(self.constructor, edit=True, subdivisionsAxis=spans)

        # select the side faces of pipe
        sideFaces = range(spans * 2, spans * 3, 2)
        faceNames = []

        for face in sideFaces:
            fname = 'f[%s]' % (face)
            faceNames.append(fname)

        cmds.setAttr('%s.inputComponents' % (self.extrude), len(faceNames), *faceNames, type="componentList")

        cmds.polyExtrudeFacet(self.extrude, edit=True, localTranslateZ=length)
    def change_teeth(self, teeth=10, length=0.3):
        """
        This function will change an existing gear with the given perameters.
        
        Args:
            teeth: The number of teeth to create
            length: The length of the teeth
        """
        spans = teeth * 2

        cmds.polyPipe(self.constructor, edit=True, subdivisionsAxis=spans)

        side_faces = range(spans * 2, spans * 3, 2)
        face_names = []

        for face in side_faces:
            face_name = "f[{}]".format(face)
            face_names.append(face_name)

        cmds.setAttr("{0}.inputComponents".format(self.gearextrude),
                     len(face_names),
                     *face_names,
                     type="componentList")
        cmds.polyExtrudeFacet(self.gearextrude,
                              edit=True,
                              localTranslateZ=length)
def gear_teeth_modifier(constructor, extrude, standard_teeth=10, length=0.3):
    """
    Change the number of teeth on a gear with a given number of teeth and a given length for the teeth.
    This will create a new extrude node.

    Args:
        constructor (str): the constructor node
        extrude (str): the extrude node
        teeth (int): the number of teeth to create
        length (float): the length of the teeth tp create
    """

    spans = standard_teeth * 2;

    # Modifying its attributes instead of creating a new one
    cmds.polyPipe(constructor, edit=True, subdivisionsAxis=spans)

    # List of faces to extrude as teeth
    side_faces = range(spans * 2, spans * 3, 2)
    face_names = []

    # Collecting the face names
    for face in side_faces:
        face_name = "f[%s]" % face
        face_names.append(face_name)

    # cmds.setAttr('extrudeNode.inputComponents', numberOfItems, item1, item2, item3, type='componentList')
    # Example cmds.setAttr('extrudeNode.inputComponents', 2, 'f[1]', 'f[2]', type='componentList'

    cmds.setAttr("%s.inputComponents" % extrude, len(face_names), *face_names, type="componentList")

    cmds.polyExtrudeFacet(extrude, edit=True, ltz=length)
def changeGear(transform, constructor, extrudeNode, teeth = 5, length = 0.2):
    '''
    this function will change target gearlike geo's teeth number and teeth length
    :param transform: transform node
    :param constructor: mesh constructor
    :param extrudeNode: extrudenode
    :param teeth: new number of teeth
    :param length: new number of teeth length
    :return: 0
    '''
    spin = teeth*2
    ##use edit flag to change target meshNode(constructor)
    cmds.polyPipe(constructor, edit = True, subdivisionsAxis=spin)
    faceNum = range(spin * 2, spin * 3, 2)

    cmds.select(clear=True)

    newFaceList = []
    for face in faceNum:
        #build a new extrudeFaceList to upgrade the Node
        newFaceList.append("f[%s]" % (face))
    ##ust need to edit the current extrude attr
    print newFaceList;
    ##use setAttr to specify the new list of extrude faces
    cmds.setAttr("%s.inputComponents" % (extrudeNode), len(newFaceList), *newFaceList, type ='componentList')
    ##it seems can use cmds.xxxnode(edit = True) to change it's flag value
    cmds.polyExtrudeFacet(extrudeNode, edit=True, ltz=length)
    return 0
示例#9
0
def a_ring():
	
	ring_diameter = 22 # outer diameter 
	ring_thickness = 1.5
	divit_diameter = 1.5
	divit_depth = .75
	ring_height = 4
	#divit_spacing = .5

	divits = []
	cmds.polyPipe(radius=ring_diameter/2, height=ring_height*2, thickness=ring_thickness, name='ring0')
	cmds.setAttr( 'polyPipe1.subdivisionsAxis', 20 )
	
	for x in range(0,6):
		for y in range(0,3):	
			letter = initials[x]
			symbol = letter[y]
			myName = "_c" + str(x) + str(y)
			
			if symbol == 0 :
				cmds.polyCylinder(axis=[0,0,1], radius=(divit_diameter/2), height=divit_depth, name=myName)
			elif symbol == 2:
				cmds.polyCylinder(axis=[0,0,1], radius=(divit_diameter/2), height=ring_thickness * 2.1, name=myName)
		
			if symbol != 1:
				divits.append(myName)	
				y_off = 0
				cmds.move(0,y_off,(ring_diameter/2 - divit_depth/2 + .3),myName)
				cmds.rotate(0,(x*3+y)*20,0,myName, pivot=[0,0,0])
		
	rn = 0;	
	for d in divits[:]:
		print 'ring' + str(rn) + " " + d
		cmds.polyBoolOp('ring' + str(rn), d, op=2, n='ring' + str(rn+1), )
		rn += 1
def makeBeamPipe( block, x, cubeDimX, cubeDimY, cubeDimZ ):
    innerPipe = cmds.polyPipe( r=cubeDimY * 0.5, h=cubeDimX*2, t=0.05, ax=(1,0,0) )
    innerAdd = cmds.polyPipe( r=cubeDimY * 0.45, h=cubeDimX*1.64, t=0.1, ax=(1,0,0) )
    inner = cmds.polyCBoolOp( innerPipe[0], innerAdd[0], op=1, ch=False )
    cmds.move( (x*0.8) - (cubeDimZ/2.0), moveZ= True, a=True)  
    cmds.move( (cubeDimY * 0.5), moveY= True, a=True) 
    block =  cmds.polyCBoolOp( block[0], inner[0], op=1, ch=False )
    return block    
示例#11
0
def changeTeeth(constructor, extrude, teeth, length=0.3):
    """
	Change number of teeth with a given amount of teeth and its length on an existing gear
	This will create a new extrude node
	Args:
		constructor (str): constructor node
		extrude (str): extrude node
		teeth (int): number of teeth to create
		length (int): length of the teeth to create
	"""
    # Number of spans by duplicating the number of teeth
    spans = teeth * 2

    # polyPipe cmd used to modify the gear
    # edit="true" - instead of creating a new one, edit its attributes
    # Creates new subdivisions
    cmds.polyPipe(constructor, edit=True, subdivisionsAxis=spans)

    # Now we must get a list to know what faces to extrude
    # Go through first face, and step up every two values
    sideFaces = range(spans * 2, spans * 3, 2)
    faceNames = []

    # We want to get a list in the following format:
    # [u'f[40]', u'f[42]', u'f[44]', u'f[46]', u'f[48]', u'f[50]', u'f[52]', u'f[54]', u'f[56]', u'f[58]']

    # Loop through all the side faces
    for face in sideFaces:
        # Use string substitution to create the names where 'face' = number of the face
        faceName = 'f[%s]' % (face)
        faceNames.append(faceName)

    # Set the attributes
    # Modify extrude's parameter for which components it affects
    # We use setAttr call instead of recreating the extrude which can be expensive

    # In maya cmds do....
    # listAttr('polyExtrudeFace1') - we are interested in 'inputComponents'
    # getAttr('polyExtrudeFace1.inputComponents') - return face values we have

    # The arguments to changing a list of components is slightly different than a simple setAttr
    # it is:
    #   cmds.setAttr('extrudeNode.inputComponents', numberOfItems, item1, item2, item3, type='componentList')

    # Arg1 - Pass in extrude node since we dont know what the name of extrude while running the funciton
    # Arg2 - How many items in the list we are giving it
    # Arg3 - Needs list of all the faces we will be using by expanding it by *
    # Arg4 - Tell it what kind of type the attribute is
    cmds.setAttr('%s.inputComponents' % (extrude),
                 len(faceNames),
                 *faceNames,
                 type="componentList")

    # We want to change the length of the teeth
    # 'ltz' - short form for "localTranslateZ"
    cmds.polyExtrudeFacet(extrude, edit=True, ltz=length)
示例#12
0
    def ChangeTeeth(self, teeth = 10):
        '''
          Change the teeth's number
        Args:
            teeth: Number of teeth

        '''
        cmds.polyPipe(self.node, edit = True, subdivisionsAxis = teeth * 2)

        faces = self.GetTeethFaces(teeth)
        cmds.setAttr("%s.inputComponents" % self.extrude, len(faces), * faces, type = "componentList")
示例#13
0
def changeTeeth(constructor, extrude, teeth=10, length=0.3):
    """
    Change the number of teeth on a gear with a given number of teeth and a given length for the teeth.
    This will create a new extrude node.
    Args:
        constructor (str): the constructor node
        extrude (str): the extrude node
        teeth (int): the number of teeth to create
        length (float): the length of the teeth to create
    """
    # Just like before we calculate the number of spans required by duplicating the number of teeth.
    spans = teeth * 2

    # We then use the same polyPipe command we used to create the pipe to modify it, this time providing the edit=True parameter
    # This edit parameter tells it we want to modify its attributes instead of creating a new one
    cmds.polyPipe(constructor, edit=True,
                  subdivisionsAxis=spans)

    # As we did when creating it we need to get a list of faces to extrude as teeth
    sideFaces = range(spans * 2, spans * 3, 2)
    faceNames = []

    # We need to get a list in the following format
    # [u'f[40]', u'f[42]', u'f[44]', u'f[46]', u'f[48]', u'f[50]', u'f[52]', u'f[54]', u'f[56]', u'f[58]']

    # So we'll loop through all the sidefaces
    for face in sideFaces:
        # And we'll use the string substitution to create the names
        # In this case, %s will be replaced by 'face' which is the number of our face
        faceName = 'f[%s]' % (face)

        # We'll add this to our list of faceNames
        faceNames.append(faceName)

    # Then we must modify the extrude's parameter for which components it affects.
    # This takes a few different arguments

    # The extrude node has an attribute called inputComponents
    # To change it we can use a simple setAttr call instead of recreating the extrude which can be expensive
    # The arguments to changing a list of components is slightly different than a simple setAttr
    # it is:
    #   cmds.setAttr('extrudeNode.inputComponents', numberOfItems, item1, item2, item3, type='componentList')
    cmds.setAttr('%s.inputComponents' % (extrude),
                 len(faceNames),
                 *faceNames,
                 type="componentList")

    # The *faces will be new to you.
    # It basically means to expand a list in place for arguments
    # so if the list has ['f[1]', 'f[2]'] etc, it will be expanded in the arguments to be like this
    # cmds.setAttr('extrudeNode.inputComponents', 2, 'f[1]', 'f[2]', type='componentList'

    cmds.polyExtrudeFacet(extrude, edit=True, ltz=length)
示例#14
0
 def changeTeeth(self, constructor, extrude, teeth=10, length=0.3):
     spans = teeth * 2
     cmds.polyPipe(self.constructor, edit=True, sa=spans)
     sideFaces = range(spans * 2, spans * 3, 2)
     faceNames = []
     for face in sideFaces:
         faceName = 'f[%s]' % (face)
         faceNames.append(faceName)
     cmds.setAttr('%s.inputComponents' % (extrude),
                  len(faceNames),
                  *faceNames,
                  type="componentList")
     cmds.polyExtrudeFacet(self.extrude, edit=True, ltz=length)
示例#15
0
def changeTeeth(constructor, extrude, teeth = 10, length = 0.3):
    spans = teeth * 2

    cmds.polyPipe(constructor, edit = True, sa = spans)
    sideFaces = range(spans * 2, spans * 3, 2)
    newSideFaces = []

    for face in sideFaces:
        faceName = "f[%s]" % (face)
        newSideFaces.append(faceName)

    cmds.setAttr("%s.inputComponents" % (extrude), len(newSideFaces), *newSideFaces, type = "componentList")
    cmds.polyExtrudeFacet(extrude, edit = True, ltz = length)
示例#16
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)
示例#17
0
def makeStreetTree(shaders):
    '''
    Creates a tree on a circular platform and with a circular fence around it.
    
    shaders: A list of shaders for the tree crowns.
    On exit: A tree has been created using makeTree(...), a circular platform
             has been created underneath it and a fence around it. Appropriate 
             shaders have been assigned. Everything is united into one polygonal
             object and returned as a tuple with the object name and the node 
             name.
    '''
    tree = makeTree(shaders)
    platform = cmds.polyCylinder(name = "platform",h = 0.1, r = 0.8)
    cmds.move(0.25, y = True)
    cmds.sets(platform[0], edit=True, forceElement="fountainMaterialGroup")
    pole = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04)
    cmds.xform(pole, t = (0.7,0.45,0))
    angle = 360/10.0
    for i in range(1,10):
        pole1 = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04)
        cmds.rotate(angle * i, y = True)
        cmds.move(0.7,0.45,0, os = True)
        pole = cmds.polyUnite(pole, pole1)
    bar = cmds.polyPipe(name = "bar", h = 0.1, r = 0.65, t = 0.04)
    cmds.move(0.65, y = True)
    bar1 = cmds.duplicate(bar[0])
    cmds.move(-0.2, y = True, r = True)
    fence = cmds.polyUnite(pole, bar, bar1)
    cmds.sets(fence[0], edit=True, forceElement="blackMetalGroup")
    streetTree = cmds.polyUnite(tree,platform, fence)
    cmds.delete(streetTree, ch = True)
    return streetTree
示例#18
0
def createGear(teeth=10, length=0.3):
    """
    This function will create a gear mesh procedurally
    :param teeth: number of teeth to create
    :param length: how long is the extrusion of the teeth
    :return:Tuple of the transform, constructor and extrude node
    """
    # teeth are alternative face so spans times 2
    spans = teeth * 2

    transform, constructor = cmds.polyPipe(subdivisionsAxis=spans)

    # side face index:  start---end-----every 2
    # range create a sequence like this
    sideFaces = range(spans * 2, spans * 3, 2)

    cmds.select(clear=True)

    for face in sideFaces:
        cmds.select("%s.f[%s]" % (transform, face), add=True)

    extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]
    print(extrude)

    return transform, constructor, extrude
示例#19
0
def createGear(teeth = 10, len = 0.3):
    """
    Create a gear with the given parameter.

    Args:
        teeth (int, optional): number of teeth to create. Defaults to 10.
        len (float, optional): length of teeth. Defaults to 0.3.

    Returns:
        tuple: a tuple of (transform, constructor, extrude face)
    """
    # teeth are every other face
    spans = teeth * 2

    # 
    transform, constructor = cmds.polyPipe(sa = spans)

    # this is because the faces we want in Maya are numbered from [spans * 2, spans * 3)
    # *** if you run ls -sl in MEL, Maya gives you all the face names
    sideFaces = range(spans * 2, spans * 3, 2)

    # clear any selection you have
    cmds.select(clear = True)

    # iterate through every other side face
    for face in sideFaces:
        cmds.select("%s.f[%s]" % (transform, face), add = True)

    # get the poly extrude face
    extrude = cmds.polyExtrudeFacet(ltz = len)[0]

    #clean up and return
    cmds.select(clear = True)
    return transform, constructor, extrude
    def create_gear(self, teeth=10, length=0.3):
        """
        This function will create a gear with the given perameters.
        
        Args:
            teeth: The number of teeth to create
            length: The length of the teeth
        """

        #print("Creating Gear: {0} Teeth and {1} Length".format(teeth, length))

        # Teeth are on alternate faces so we will span x 2
        spans = teeth * 2

        self.transform, self.constructor = cmds.polyPipe(
            subdivisionsAxis=spans)

        side_faces = range(spans * 2, spans * 3, 2)

        cmds.select(clear=True)

        for face in side_faces:
            cmds.select("{0}.f[{1}]".format(self.transform, face), add=True)

        self.gearextrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]
示例#21
0
    def createPipe(self, spans):
        self.transform, self.shape = mc.polyPipe(sa=spans)

        for node in mc.listConnections('%s.inMesh' % self.transform):
            if mc.objectType(node) == 'polyPipe':
                self.constructor = node
                break
def createGear(teeth=10, length=0.3):
    """
    This function will create a gear with the given parameters
    :param
    teeth: The number of teeth to create
    :param
    length: The length of the teeth
    :return:
    A tuple of the transform, constructor and extrude node
    """
    # Teeth are every alternate face, so spans x 2
    spans = teeth * 2

    transform, constructor = cmds.polyPipe(subdivisionsAxis=spans)

    sideFaces = range(spans * 2, spans * 3, 2)

    cmds.select(clear=True)

    for face in sideFaces:
        cmds.select('%s.f[%s]' % (transform, face), add=True)

    extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]

    return transform, constructor, extrude
示例#23
0
def createGear(teeth=10, length=0.3):

    sele = cmds.select("gearpipe")

    cmds.delete()

    print "creating gear", teeth, length

    span = teeth * 2
    #global span
    transfo_node, shape_node = cmds.polyPipe(subdivisionsAxis=span,
                                             n="gearpipe")

    print transfo_node

    print shape_node

    sideface = range(span * 2, span * 3, 2)

    cmds.select(clear=True)

    for face in sideface:
        cmds.select('%s.f[%s]' % (transfo_node, face), add=True)

    extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]
    print extrude

    cmds.select(clear=True)

    return transfo_node, shape_node, extrude
示例#24
0
def createGear(teeth=10, length=0.3):
    """
    This function will create a gear with the given parameters
    Args:
        teeth: The number of teeth to create
        length: The length of the teeth
    Returns:
        A tuple of the transform, constructor and extrude node
    """

    spans = teeth * 2

    transform, constructor = cmds.polyPipe(subdivisionsAxis=spans)

    sideFaces = range(spans * 2, spans * 3, 2)

    # clear the selection to add each face to it
    cmds.select(clear=True)

    for face in sideFaces:
        cmds.select('%s.f[%s]' % (transform, face), add=True)

    #  extrude the selected faces by the given length
    # returns value of the extrude node inside a list
    extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]

    # return a tuple of (transform, constructor, extrude)
    return transform, constructor, extrude
示例#25
0
def generar_tuerca(teeth=10, length=0.3):
    """Funcion que crea una tuerca con los parametros dados
    Args:
        teeth: El numero de dientes de la tuerca
        length: Tamano de cada tuerca
    
    Returns:
        Una tupla con la transformada, el constructor y el nodo que hace la extruccion
    """
    # Teeth (dientes) son cada una de las caras que es extruida
    spans = teeth * 2
    
    transform, constructor = cmds.polyPipe(subdivisionsAxis=spans)
    
    #select -r pPipe1.f[40] pPipe1.f[42] pPipe1.f[44] pPipe1.f[46] pPipe1.f[48] pPipe1.f[50] pPipe1.f[52] pPipe1.f[54] pPipe1.f[56] pPipe1.f[58] ;
    sideFaces = range(spans*2, spans*3, 2)
    
    print(transform, constructor, sideFaces)
    
    cmds.select(clear=True)
    
    for face in sideFaces:
        cmds.select("%s.f[%s]" % (transform, face), add=True)
        
    #polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx -1.192092896e-07 -pvy 0 -pvz 1.788139343e-07 -divisions 1 -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30 pPipe2.f[40] pPipe2.f[42] pPipe2.f[44] pPipe2.f[46] pPipe2.f[48] pPipe2.f[50] pPipe2.f[52] pPipe2.f[54] pPipe2.f[56] pPipe2.f[58];
    #setAttr "polyExtrudeFace2.localTranslate" -type double3 0 0 0.143625 ;
    extruded_faces = cmds.polyExtrudeFacet(localTranslateZ=length)
    return transform, constructor, extruded_faces
示例#26
0
def makeGear(teeth = 10, length = 0.5):
    '''
    this function will create a gear according to specified number of teeth and length
    :param teeth: number of teeth that gear has
    :param length: number of teeth length
    :return: 1.transform node 2. meshconstructor 3. extrudeNode
    '''
    removeGear()
    spin = teeth * 2
    #total side face number = teeth number * 2
    transform, constructor = cmds.polyPipe(subdivisionsAxis=spin, name='Gear')

    ##calculate sideFaceID from spin*2 to spin*3 at intervals of one
    faceNum = range(spin * 2, spin * 3, 2)


    ##clean everySelection
    cmds.select(clear=True)
    for face in faceNum:
        print face
        ##select target faces based of sideFaceID
        cmds.select("%s.f[%s]" % (transform, face), add=True) or []
    ##set  localTranslateZ flag to make the length of gear
    extrudeAttr = cmds.polyExtrudeFacet(ltz = length)[0]

    print extrudeAttr
    print transform, constructor
    return  transform,constructor,extrudeAttr
示例#27
0
  def generate(cls, *args):
    components = []
    radius = cmds.intSliderGrp(cls.get_prefix() + Labels["radius_label"], query=True, value=True)
    height = cmds.intSliderGrp(cls.get_prefix() + Labels["height_label"], query=True, value=True)
    subdivs = cmds.intSliderGrp(cls.get_prefix() + Labels["subdivs_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)
    wheel_radius = radius * Constants["wheel_radius_unit"]
    wheel_height = height * Constants["wheel_height_unit"]
    
    wheel_component = cmds.polyPipe(name=get_unique_name(cls.get_prefix(), "cylender"), sh=4, sc=subdivs, h=wheel_height, r=wheel_radius)
    wheel_extrusion_faces = []
    cmds.select(r=True)

    for i in range(0, subdivs):
      if i % 2 == 1:
        facet_title = wheel_component[0] + ".f[" + str(i) + "]"
        wheel_extrusion_faces.append(facet_title)

    #cmds.polyExtrudeFacet(wheel_extrusion_faces, ltz=Constants["wheel_ridge_depth"])
    cmds.delete(ch=1)
    cmds.lattice(wheel_component[0],divisions=[2,3,2], name=get_unique_name(cls.get_prefix(),"lattice"), cp=wheel_component[0])
    shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
    cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
    cmds.select(wheel_component[0], r=True)
    cmds.hyperShade(assign=shader)
	def generate_gear(self, teeth=10, length=0.3):
		"""
		Generates a gear mesh
		Args:
			teeth: How many teeth the gear will have
			length: How long each teeth will be
		"""
		subdivisions_axis = teeth * 2

		# Assigns pPipe to transform and polyPipe input node to poly_pipe_constructor
		self.transform, self.poly_pipe_constructor = cmds.polyPipe(subdivisionsAxis=subdivisions_axis)

		# in a default 20-subdivision pipe, the numbering of the faces is as follows:
		# inner faces: 0-19,  top: 20-39, outer: 40-59, and bottom: 60-79
		# Thus, the outer faces always start counting at NumberOfSubdivisions * 2 and end at NumberOfSubdivisions * 3 -1
		# since the upper limit of range() is exclusive, we don't have to do the "-1"
		outer_side_faces = range(subdivisions_axis * 2, subdivisions_axis * 3, 2)
		# print("outer_side_faces: " + str(outer_side_faces))  # the faces that will be extruded

		cmds.select(clear=True)

		# select all the faces to extrude
		for face in outer_side_faces:
			# transform_name.f allows you to access a list containing all the faces of the mesh
			# "add' means the next face we select is added to the selection w/o deselecting previously selected faces
			cmds.select("%s.f[%s]" % (self.transform, face), add=True)

		# extrudes the selected faces and returns the polyExtrudeFace node that is fed into the pPipeShape node
		self.extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]
示例#29
0
    def create(self, teeth=10, length=0.3):
        """
        This function will create a gear mesh procedurally
        :param teeth: number of teeth to create
        :param length: how long is the extrusion of the teeth
        """
        # teeth are alternative face so spans times 2
        spans = teeth * 2

        self.transform, self.constructor = cmds.polyPipe(
            subdivisionsAxis=spans)

        # side face index:  start---end-----every 2
        # `range` create a sequence like this
        side_faces = range(spans * 2, spans * 3, 2)

        # how cmd works is selection load/unload at runtime
        cmds.select(clear=True)

        for face in side_faces:
            cmds.select("%s.f[%s]" % (self.transform, face), add=True)

        self.extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]

        if self.debug:
            print(self.extrude)
示例#30
0
def createGear(teeth=10, length=0.3):
    """
    This function will create a gear with the given params
    Args: 
        teeth: number of teeth
        length: the length
    Returns:  
        A tuple with the transform, constructor and extrude node
    """
    # teeth are every alternate face, spans = teeth * 2
    spans = teeth * 2
    transform, constructor = cmds.polyPipe(sa=spans)
    # selection of the faces
    sideFaces = range(spans * 2, spans * 3,
                      2)  # between 40 and 60 and every second number
    # clear selection
    cmds.select(clear=True)
    # faceSelection
    for face in sideFaces:
        cmds.select('%s.f[%s]' % (transform, face), add=True)
    # extrude faces
    extrude = cmds.polyExtrudeFacet(localTranslateZ=length)[0]
    #unselect
    cmds.select(cl=True)
    # we print
    print("the final polyelement is: " + extrude)
    # we return for futur use
    return transform, constructor, extrude
示例#31
0
 def createGear(self, teeth=10, length=0.3):
     spans = teeth * 2
     self.transform, self.constructor = cmds.polyPipe(sa=spans)
     sideFaces = range(spans * 2, spans * 3, 2)
     cmds.select(clear=True)
     for face in sideFaces:
         cmds.select('%s.f[%s]' % (self.transform, face), add=True)
     self.extrude = cmds.polyExtrudeFacet(ltz=length)[0]
示例#32
0
def changeTeeth(constructor, extrude, teeth=10, length=0.3):
    spans = teeth * 2
    cmds.polyPipe(constructor, edit=True, subdivisionsAxis=spans)

    sideFaces = range(spans * 2, spans * 3, 2)
    facesNames = []

    for face in sideFaces:
        facesName = 'f[%s]' % (face)
        facesNames.append(facesName)

    cmds.setAttr('%s.inputComponents' % (extrude),
                 len(facesNames),
                 *facesNames,
                 type="componentList")

    cmds.polyExtrudeFacet(extrude, edit=True, localTranslateZ=length)
def HoleConnector():
     
    components = []
    
    # Fetching slider data 
    rgb = cmds.colorSliderGrp('HoleColour', query=True, rgbValue=True) 
      
    cmds.select(clear=True) 
     
    cubeDimX = 0.74
    cubeDimY = 0.78
     
    # Inner tube    
    innerCyl = cmds.polyPipe( r=cubeDimY * 0.40, h=cubeDimX*3.85, t=0.1, ax=(1,0,0), ch=False )
     
    # End Ring
    endCyl1 = cmds.polyPipe( r=cubeDimY * 0.45, h=cubeDimX*0.1, t=0.05, ax=(1,0,0), ch=False )
    cmds.move(cubeDimX*1 - (cubeDimX*0.05),0,0)
     
    midShape =  cmds.polyCBoolOp( innerCyl[0], endCyl1[0] , op=1, ch=False)
     
    # Subtraction cube
    endCube1 = cmds.polyCube(width=0.5, height=0.09, depth=1, ch=False)
    cmds.move(cubeDimX*1 - (cubeDimX*0.15),0,0)
     
    midShape = cmds.polyCBoolOp( midShape[0], endCube1[0], op=2, ch=False )
     
    # End Ring 2
    endCyl2 = cmds.polyPipe( r=cubeDimY * 0.45, h=cubeDimX*0.1, t=0.05, ax=(1,0,0), ch=False )
    cmds.move((cubeDimX*0.05) - cubeDimX*1,0,0)
     
    midShape =  cmds.polyCBoolOp( midShape[0], endCyl2[0] , op=1, ch=False)
     
    # Subtraction cube 2
    endCube2 = cmds.polyCube(width=0.5, height=0.09, depth=1, ch=False)
    cmds.move((cubeDimX*0.15) - cubeDimX*1,0,0)
     
    midShape = cmds.polyCBoolOp( midShape[0], endCube2[0], op=2, ch=False )
     
    outerCyl1 = cmds.polyPipe( r=cubeDimY * 0.45, h=cubeDimX*0.2, t=0.05, ax=(1,0,0),ch=False )
     
     
    finalShape =  cmds.polyCBoolOp( midShape[0], outerCyl1[0], op=1, ch=False )
     
    # Adding on the color
    shadedShape = addShader(finalShape, rgb)    
def holeBlock():
    blockWidth = cmds.intSliderGrp('holeWidth', q=True, v=True)
    rgb = cmds.colorSliderGrp('holeColour', q=True, rgbValue=True)

    global nextBlockId
    nsTmp = "Block" + str(nextBlockId)
    nextBlockId = nextBlockId + 1
    createNamespace(nsTmp)

    cubeSizeX = (blockWidth) * 0.8
    cubeSizeZ = 0.8
    cubeSizeY = .96

    #Create Cube
    cmds.polyCube(width=cubeSizeX,
                  height=cubeSizeY,
                  depth=cubeSizeZ,
                  sh=2,
                  sd=2)
    cmds.move(0, (cubeSizeY / 2), 0)

    #separate loop for punching holes
    for i in range(blockWidth - 1):
        moveX = (((i + .5) * 0.8) - (cubeSizeX / 2.0) + 0.4)
        punchHole(.25, 2, 90, moveX, .5, nsTmp, ":pCube1", "pCube1")

    #add bumps to cube and also rename it to pCube1 for loop friendly code
    for i in range(blockWidth):
        #Create pipe, used to make bump
        cmds.polyPipe(r=.25, h=.4, t=.05)
        cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True)
        cmds.move((cubeSizeY + 0.10), moveY=True, a=True)
        BOOLEAN(nsTmp, ":pPipe1", ":pCube1", 1, "pCube1")

    myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat")
    cmds.setAttr(nsTmp + ":blckMat.color",
                 rgb[0],
                 rgb[1],
                 rgb[2],
                 typ='double3')

    #since there is no need for unite, one last rename to nsTMP to add texture
    cmds.select(nsTmp + ":pCube1")
    cmds.rename(nsTmp)
    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
示例#35
0
    def create_pipe(self):
        # Setting the shape and transform to the class variables
        self.transform, self.shape = cmds.polyPipe(subdivisionsAxis=self.spans)

        # Finding the polyPipe node and set it equal to the constructor
        for node in cmds.listConnections("{0}.inMesh".format(self.transform)):
            if cmds.objectType(node) == "polyPipe":
                self.constructor = node
                break
    def changeGear(self, teeth = 5, length = 0.2):
        spin = teeth * 2
        ##use edit flag to change target meshNode(constructor)
        cmds.polyPipe(self.constructor, edit=True, subdivisionsAxis=spin)
        faceNum = range(spin * 2, spin * 3, 2)

        cmds.select(clear=True)

        newFaceList = []
        for face in faceNum:
            # build a new extrudeFaceList to upgrade the Node
            newFaceList.append("f[%s]" % (face))
        ##ust need to edit the current extrude attr
        print newFaceList;
        ##use setAttr to specify the new list of extrude faces
        cmds.setAttr("%s.inputComponents" % (self.extrudeNode), len(newFaceList), *newFaceList, type='componentList')
        ##it seems can use cmds.xxxnode(edit = True) to change it's flag value
        cmds.polyExtrudeFacet(self.extrudeNode, edit=True, ltz=length)
        return 0
示例#37
0
 def setJoints(self,rootPos, endPos, ringPos,rConstLoc,bConstLoc,radius,jntName,pGroup):
     
     thickness = radius/3
     
     
     #clear selection
     mc.select(clear=True)
     #create joints
     joints=[]
     
     joints.append(mc.joint(position=rootPos,name=(jntName+"_root_JNT_#")))
     joints.append(mc.joint(position=ringPos,name=(jntName+"_end_JNT_#")))
    
     
     mc.joint(joints,edit=True,orientJoint="xyz",zeroScaleOrient=True,
              secondaryAxisOrient="yup")
     
     #create IKhandle
     self.pistonIK=mc.ikHandle(sj=joints[0], ee=joints[1], 
                               name=(jntName+"_IK_#"))
     
     #parent to locators
     mc.parent(joints[0],rConstLoc)
     
     #constrain to locators
     mc.pointConstraint(bConstLoc,self.pistonIK[0])
     
     
     #distance between 
     distance = sqrt( pow((rootPos[0]-ringPos[0]),2) + 
                      pow((rootPos[1]-ringPos[1]),2) + 
                      pow((rootPos[2]-ringPos[2]),2))
     
            
     #create pipe rod (polyPipe bug...must double the height)
     self.rod=mc.polyPipe(r=radius,t=thickness,h=(distance*2),
                          sa=20,ax=(0,1,0),cuv=3,ch=1,sc=0,
                          name=(jntName+"_geo_#"))
     #move pivot point to origin
     
     mc.xform(pivots=(0,(distance/-2),0))
     #aim and parent to joints
     mc.pointConstraint(joints[0],self.rod[0])
     mc.aimConstraint(joints[1],self.rod[0],aimVector=(0,1,0))
     
     #clear the list
     del joints[:]
     
     mc.select(self.pistonIK[0],self.rod[0])
     mc.ls(sl=True)[0]
     toGroup=mc.group(n=jntName+"_GRP_#")
     mc.parent(toGroup, pGroup)
示例#38
0
def make_pipe(new_radius, new_height, basename="pipe_000", from_pipe_name=None):
    t = 1/float(16)  # 16ga
    if from_pipe_name:
        ret = cmds.duplicate(from_pipe_name, un=True)
        log.debug(ret)
        new_name = ret[0]
        shape = ret[-1]
    else:
        new_name, shape = cmds.polyPipe(n=basename, t=t)

    log.debug("copied: " + new_name if from_pipe_name else "new: " + new_name)
    cmds.setAttr(shape + '.radius', new_radius)
    cmds.setAttr(shape + '.height', new_height*2)
    return new_name, shape
    def makeGear(self, teeth=10,length=0.5):
        self.removeGear(self.name)
        spin = teeth * 2
        # total side face number = teeth number * 2
        transform, constructor = cmds.polyPipe(subdivisionsAxis=spin, name=self.name)

        ##calculate sideFaceID from spin*2 to spin*3 at intervals of one
        faceNum = range(spin * 2, spin * 3, 2)

        ##clean everySelection
        cmds.select(clear=True)
        for face in faceNum:
            print face
            ##select target faces based of sideFaceID
            cmds.select("%s.f[%s]" % (transform, face), add=True) or []
        ##set  localTranslateZ flag to make the length of gear
        extrudeAttr = cmds.polyExtrudeFacet(ltz=length)[0]

        print transform, constructor, extrudeAttr
        self.transform = transform
        self.constructor = constructor
        self.extrudeNode = extrudeAttr
        return  0
def PolyPipes(\
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.polyPipe( sh=1, h=1, n='pipe{}'.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, 'pipe{}'.format(i))
    	
    	cmds.scale(scaleF, scaleF, scaleF, 'pipe{}'.format(i))
    	
    	cmds.move( x, y, z, 'pipe{}'.format(i))
    	
    	cmds.sets( name='PipeMaterial{}'.format(i), renderable=True, empty=True )
    	cmds.shadingNode( 'phong', name='PipeShader{}'.format(i), asShader=True )
    	cmds.setAttr( 'PipeShader{}'.format(i)+'.color', r, g, b, type='double3' )
    	cmds.surfaceShaderList( 'PipeShader{}'.format(i), add='PipeMaterial{}'.format(i))
    	cmds.sets( 'pipe{}'.format(i), forceElement='PipeMaterial{}'.format(i)) 
示例#41
0
def pipe(radius, height, name=None):
    t = 1/float(16)  # 16ga
    val = cmds.polyPipe(
        thickness=t, radius=radius, height=height*2, name=name)
    log.debug(val)
    return val
示例#42
0
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)
mc.move(-6, 0, -6, pipe, r=True)
mc.rotate(14, 32, 30, pipe, r=True, os=True)

helix = mc.polyHelix(c=3, h=2, w=2, r=0.4, sa=8, sco=50, sc=0, d=1, ax=(0, 1, 0), cuv=3, rcp=0, ch=1)
mc.scale(2, 2, 2, helix, r=True)
mc.move(0, 0, 0, helix, r=True)
mc.rotate(14, 32, 90, helix, r=True, os=True)

# Deselect all 
mc.select(clear=True)
示例#43
0
import maya.cmds as cmds

cmds.polyCylinder(n='TourBase',r=3,h=6)
cmds.xform(ws=True, piv=(0,3,0))
cmds.move(0,-3,0)

for i in range(2):
    cmds.polyCylinder(n='Tour1',r=3.2+(.1*i),h=0.3,sa=30)
    cmds.move(0,0.3*i,0)
    
cmds.group('Tour*',n='GroupTour')
cmds.select('GroupTour')
cmds.xform(ws=True, piv=(0,0.75,0))
cmds.move(0,-0.75,0, 'GroupTour')

cmds.polyPipe(n='Remp',r=3.4,h=2.5,t=0.5,sa=40)

for i in range(12):
    cmds.polyCube(n='Rempart',w=0.5,h=0.5,d=1)
    cmds.xform(ws=True,piv=(0,-.25,0))
    cmds.move(0,.25,0)
    cmds.move(0,.2,3.2, relative=True)
    cmds.xform(ws=True, rotatePivot=(0,0,0))
    cmds.rotate(0,30*i,0)


for i in range(12):
    cmds.polyCube(n='Fente',w=1,h=.5,d=.1)
    cmds.move(3.2,0,0, relative=True)
    cmds.xform(ws=True, rotatePivot=(0,0,0))
    cmds.rotate(0,30*i,0)
示例#44
0
 def _polyPipe(self):
     cmds.polyPipe()
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 tyre():
    
    #get values from UI
    rgb = cmds.colorSliderGrp('wheelColour', query=True, rgbValue=True)
    
    #set up variables
    radius = 2.85
    widthHalf = 2.7
    
    ridgeShapeList = []
    
    innerCircle = cmds.polyPipe( h = widthHalf * 0.7, r = 2.65, t = 1.05 )
    outerCircle = cmds.polyPipe( h = widthHalf, r = 2.65, t = 0.85 )
    ridge1 = cmds.polyPipe( h = (widthHalf * 0.33)/2, r = 2.85, t = 0.80 )
    cmds.move( -0.567, moveY = True)
    ridge2 = cmds.polyPipe( h = widthHalf * 0.33, r = 2.85, t = 0.80 )
    cmds.move( -0.120, moveY = True)
    
    tire = cmds.polyCBoolOp( innerCircle, outerCircle, op = 1 )[0]
    tire = cmds.polyCBoolOp( tire, ridge1, op = 1 )[0]
    tire = cmds.polyCBoolOp( tire, ridge2, op = 1 )[0]
    
    ridgeShape = cmds.polyCube( w = 0.63, h = 0.2, d = 0.2)
    cmds.move( -0.05, moveY = True)
    ridgeShapeL = cmds.polyCube( w = 0.2, h = 0.33, d = 0.2, sy = 2)[0]
    cmds.select( ridgeShapeL+'.vtx[4]', ridgeShapeL+'.vtx[5]')
    cmds.move( -0.09, moveZ = True )
    ridgeShapeR = cmds.duplicate( ridgeShapeL )
    cmds.move( -((0.63/2) - 0.1), 0.33/2, 0, ridgeShapeL )
    cmds.move( (0.63/2) - 0.1, 0.33/2, 0, ridgeShapeR )
    
    ridgeShape = cmds.polyCBoolOp( ridgeShape, ridgeShapeL, op = 1 )[0]
    ridgeShape = cmds.polyCBoolOp( ridgeShape, ridgeShapeR, op = 1 )[0]
    
    cmds.move( 0, 0.343, radius - 0.14)
    
    cmds.move( 0, 0, 0, ridgeShape+".scalePivot", ridgeShape+".rotatePivot", absolute=True)
    
    ridgeShapeList.append( ridgeShape )
    
    for i in range( 0, 19):
        ridgeShape = cmds.duplicate( ridgeShape )[0]
        cmds.rotate( 0, 18, 0, ridgeShape, r = True )
        ridgeShapeList.append( ridgeShape )
    
    ridges = cmds.polyUnite( *ridgeShapeList ) 
    cmds.rotate( 9, rotateY = True ) 
    tireL = cmds.polyUnite( tire, ridges )[0]
    
    cmds.rotate( 90, tireL, rotateZ = True )
    cmds.move( ((widthHalf / 2)/2), tireL, moveX = True )  
    
    tireR = cmds.duplicate( tireL )[0]
    cmds.scale( -1, scaleY = True )
    cmds.move( -((widthHalf / 2)/2), tireL, moveX = True ) 
    
    tire = cmds.polyUnite( tireR, tireL )
    
    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( tire )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )