コード例 #1
0
ファイル: base_shapes.py プロジェクト: lbmk27/maya_python
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()
コード例 #2
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)
コード例 #3
0
def makeRoundHoleBlock(blockDepth):
       
    cubeDimX = 0.74
    cubeDimY = 0.78
    cubeDimZ = (blockDepth * 0.8) - (blockDepth*0.8/blockDepth)
     
    # Make Block
    block = cmds.polyCube(width=cubeDimX, height=cubeDimY, depth=cubeDimZ, ch=False)
    cmds.move((cubeDimY/2.0), moveY=True) 
     
    # Make left endcap
    endCap = cmds.polyCylinder(r=cubeDimY * 0.5, h=cubeDimX, ax=(1,0,0), ch=False )
    cmds.move( (cubeDimZ * 0.5), moveZ=True, a=True)
    cmds.move( (cubeDimY * 0.5), moveY=True, a=True)
    block = cmds.polyCBoolOp( block[0], endCap[0], op=1, ch=False )
     
    # Make right endcap
    endCap = cmds.polyCylinder(r=cubeDimY * 0.5, h=cubeDimX, ax=(1,0,0), ch=False )
    cmds.move( (cubeDimZ * -0.5), moveZ=True, a=True)
    cmds.move( (cubeDimY * 0.5), moveY=True, a=True)
    block = cmds.polyCBoolOp( block[0], endCap[0], op=1, ch=False )
 
    cmds.xform(centerPivots = True )
     
    for z in range(blockDepth):
        block = makeBeamHole( block, z , cubeDimX, cubeDimY, cubeDimZ )
        block = makeBeamPipe( block, z , cubeDimX, cubeDimY, cubeDimZ )
     
    return block
コード例 #4
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
def createABranch(rotAxis, angle):
    global prevRot, prevPos
    '''Extract Euler angles from constructed quaternion'''
    euAngles = EulerAnglesFromAxisQuat(rotAxis, angle)

    #print toDegrees(euAngles[0])#x
    #print toDegrees(euAngles[1])#y
    #print toDegrees(euAngles[2])#z
    '''Create Cylinder'''
    branch = mc.polyCylinder(
        n='cy1', r=0.1, height=branchLength)  #axis=(dirx[0],diry[0],dirz[0]),

    #time.sleep(1)
    '''Set pivot to botton so as to rotate properly'''
    bbox = mc.exactWorldBoundingBox(branch)
    bottom = [(bbox[0] + bbox[3]) / 2, bbox[1],
              (bbox[2] + bbox[5]) / 2]  #(xmin,xmax)/2 , (zmin,zmax)/2
    #now set pivot to the bottom of the cylinder
    mc.xform(branch[0], piv=bottom, ws=True, r=True)
    cmds.refresh()
    #time.sleep(1)

    print "branchStackPos=%s" % (branchStackPos)

    #print "myposUsed=%s"%(prevPos)

    mypos = prevPos
    myrot = prevRot

    #mypos=branchStackPos.pop()
    #myrot=branchStackRot.pop()
    '''Move cylinder to the current position & the current rotation'''
    mc.xform(rotation=myrot, translation=mypos)
    cmds.refresh()
    #time.sleep(1)

    cylHeight = mc.polyCylinder(branch[0], height=True, query=True)
    '''move towards direction- push it up on the local y Axis'''
    mc.move(0, cylHeight, 0, r=True,
            os=True)  #step forward - move up in local Y
    '''Store this new branch position'''
    prevPos = mc.xform(query=True, translation=True,
                       worldSpace=True)  #keeps the previous position

    cmds.refresh()
    #time.sleep(1)
    '''Rotate and Store rotation'''
    mc.rotate(toDegrees(euAngles[0]),
              toDegrees(euAngles[1]),
              toDegrees(euAngles[2]),
              branch[0],
              r=True)  #perform relative rotation
    prevRot = mc.xform(
        query=True, rotation=True,
        worldSpace=True)  #keeps the previous rotated degree angles

    cmds.refresh()
    #time.sleep(1)

    setAngle(0)
コード例 #6
0
    def applyBtnCmd(self, *args):
        stepH = cmds.floatSliderGrp(self.stepH, q=True, value=True)
        stepW = cmds.floatSliderGrp(self.stepW, q=True, value=True)
        stepD = cmds.floatSliderGrp(self.stepD, q=True, value=True)
        numSteps = cmds.intSliderGrp(self.noStep, q=True, value=True)
        railH = cmds.floatSliderGrp(self.railH, q=True, value=True)

        totH = stepH * numSteps
        totD = stepD * numSteps
        railAngle = math.atan(totD / totH)
        rad2deg = railAngle * 180 / math.pi
        railLen = math.sqrt(totH * totH + totD * totD)

        for i in range(0, numSteps):
            cmds.polyCube(h=stepH, w=stepW, d=stepD)
            cmds.move(0, stepH * i, stepD * i)

            if railH > 0:
                cmds.polyCylinder(r=0.5, h=railH)
                cmds.move(stepW / 2, stepH * i + 0.5 * railH, stepD * i)

        if railH > 0:
            cmds.polyCylinder(r=0.5, h=railLen)
            cmds.rotate(rad2deg, 0, 0)
            cmds.move(stepW / 2, totH / 2 + railH - 0.5 * stepH,
                      totD / 2 - 0.5 * stepD)
コード例 #7
0
  def generate(cls, *args):
    components = []
    boolean = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = Constants["block_height_unit"]
    block_depth = Constants["block_depth_unit"]

    for x in range(0, width):
      stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"])
      components.append(stub[0])
      cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) + half(Constants["stub_height"]), half(Constants["block_depth_unit"]), stub[0])
      
    for x in range(0, width-1):
      hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
      boolean.append(hole[0])
      cmds.rotate('90deg', 0, 0, hole[0])
      cmds.move(Constants["block_width_unit"] * x + Constants["block_width_unit"], 0, half(Constants["block_depth_unit"]), hole[0])

    cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)
    solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
    final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )

    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(final[0], r=True)
    cmds.hyperShade(assign=shader)
コード例 #8
0
  def generate_kink_peice(cls, block_width):
    components = []
    boolean = []
    for x in range(0, block_width + 1):
      hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
      boolean.append(hole[0])
      cmds.rotate('90deg', 0, 0, hole[0])
      cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0])

    cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=Constants["block_height_unit"], depth=Constants["block_depth_unit"])
    components.append(cube[0])
    cmds.delete(cube[0] + ".f[40:47]")
    cmds.move(half(block_width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)

    #caps
    cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap"))
    cmds.rotate('90deg',0,0,cap_one[0])
    cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0])
    cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]")
    components.append(cap_one[0])

    #caps
    cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"])
    cmds.rotate('90deg','180deg',0,cap_two[0])
    cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]")
    cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0])
    components.append(cap_two[0])

    solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
    cmds.polyMergeVertex( solid[0], d=0.15 )
    cmds.delete(solid[0],ch=1)
    return cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )
コード例 #9
0
def four():

    #group MODULE
    mir = random.randint(0, 19)
    crazyR = random.randint(0, 1000)
    oven = 'Oven' + str(mir) + str(crazyR)
    cmds.group(n=oven, em=True)
    base_heigh = cmds.intSliderGrp(slider1, q=True, value=True)
    base_width = cmds.intSliderGrp(slider2, q=True, value=True)
    base_depth = cmds.intSliderGrp(slider3, q=True, value=True)

    #base:
    base = cmds.polyCube(h=base_heigh, w=base_width, depth=base_depth)
    cmds.polyBevel3(base, offset=0.1)
    door = cmds.polyCube(h=base_heigh - base_heigh / 2,
                         w=base_width - base_width / 2,
                         depth=0.2)
    cmds.move(0, -base_heigh / 20.0, -base_width / 2.0)
    cmds.parent(base, door, oven)
    #swiches:
    sdoor = cmds.ls(door)
    for i in range(3):
        switch = cmds.polySphere(sx=5, sy=5, r=0.2)
        cmds.move(-base_width / 4.0 + i - 0.2 * i, base_heigh / 2.5,
                  -base_width / 2.1)
        cmds.parent(switch, oven)
    for i in range(2):
        heatersOne = cmds.polyCylinder(sx=7, sy=7, h=0.2, r=base_width / 1000)
        cmds.move(-base_width / 6.0 + i, base_heigh / 2.0, -base_width / 3.5)
        cmds.parent(heatersOne, oven)
    for i in range(2):
        heaterTwo = cmds.polyCylinder(sx=7, sy=7, h=0.2, r=base_width / 1000)
        cmds.move(-base_width / 6.0 + i, base_heigh / 2.0, base_width / 3.5)
        cmds.parent(heaterTwo, oven)
コード例 #10
0
 def __init__(self, name_, height, radius, sides, shader):
     '''
     Initializes a CylinderHouse object, and creates a polygonal house object based on a
     cylinder 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.
     shader: Shader that will be assigned to the house. 
     On exit: A CylinderHouse object has been initialized and a polygonal house has 
              been created out of a cylinder 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_, "cylinder", height, radius * 2, radius * 2)
     self.radius = radius
     self.sides = sides
     n = cmds.polyCylinder(n = name_, r = radius, h = height, sx = sides, sy = height)
     cmds.xform(n[0], translation = (0,height/2.0,0))
     f = cmds.polyCylinder(n = "foundation", r = radius + 0.15, height = 0.8, sx = 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)
コード例 #11
0
def roundPlate():
    
    #get values from UI
    rgb = cmds.colorSliderGrp('brickColour', query=True, rgbValue=True)
    transparent = cmds.checkBox('makeTransparent', query = True, value = True)
    
    base = cmds.polyCylinder( h = 0.18, r = 0.3 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18/2, moveY = True)
    
    wide = cmds.polyCylinder( h = 0.14, r = 0.4 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18 + (0.14/2), moveY = True)
    
    stud = cmds.polyCylinder( h = 0.18, r = 0.24 )
    cmds.rotate( 90, rotateY = True )
    cmds.move( 0.18 + 0.14 + (0.18/2), moveY = True)
    
    rp = cmds.polyUnite( base, wide, stud )
    
    myShader = cmds.shadingNode( 'phong', asShader=True )
    cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
    cmds.setAttr( myShader+".reflectivity", 0 )
    
    if( transparent == True ):
       cmds.setAttr( myShader+".transparency", 0.5, 0.5, 0.5, type = 'double3' ) 
    
    cmds.select( rp )
    cmds.hyperShade( assign = myShader )
    
    cmds.delete( ch = True )
コード例 #12
0
    def __createPolyFromList(self, *args):
        # first, let's assign our combo box
        polyList = self.polygonList_cmbbx.currentText()
        '''
        you also can use .currentIndex() if that suit you
        '''

        if polyList == "Sphere":
            #do this
            cmds.polySphere()

        elif polyList == "Cube":
            #do this
            cmds.polyCube()

        elif polyList == "Cylinder":
            #do this
            cmds.polyCylinder()

        elif polyList == "Cone":
            #do this
            cmds.polyCone()

        else:
            #give warning message
            cmds.warning("There's no such thing like that.")
コード例 #13
0
def createSideEdgesAxel(length, distance1, distance2):

    cyl1 = cmds.polyCylinder(r=0.15, h=length + 0.1, sz=4, sy=24)
    cmds.rotate(90, 0, 0)
    cmds.move((distance1), moveY=True, a=True)
    cmds.move((distance2), moveX=True, a=True)
    cmds.move((-1 * (0.003)), moveZ=True, a=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(cu[0], cyl1[0], op=2, n="block", ch=False)

    cyl2 = cmds.polyCylinder(r=0.15, h=length + 0.1, sz=4, sy=12)
    cmds.rotate(90, 0, 0)
    cmds.move((distance1), moveY=True, a=True)
    cmds.move((-1 * (distance2)), moveX=True, a=True)
    cmds.move((-1 * (0.003)), moveZ=True, a=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(cu[0], cyl2[0], op=2, n="block", ch=False)

    cyl3 = cmds.polyCylinder(r=0.15, h=length + 0.1, sz=4, sy=12)
    cmds.rotate(90, 0, 0)
    cmds.move((-1 * (distance1)), moveY=True, a=True)
    cmds.move((distance2), moveX=True, a=True)
    cmds.move((-1 * (0.003)), moveZ=True, a=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(cu[0], cyl3[0], op=2, n="block", ch=False)

    cyl4 = cmds.polyCylinder(r=0.15, h=length + 0.1, sz=4, sy=12)
    cmds.rotate(90, 0, 0)
    cmds.move((-1 * (distance1)), moveY=True, a=True)
    cmds.move((-1 * (distance2)), moveX=True, a=True)
    cmds.move((-1 * (0.003)), moveZ=True, a=True)
    cmds.delete(ch=True)
    cu[0] = cmds.polyBoolOp(cu[0], cyl4[0], op=2, n="block", ch=False)
コード例 #14
0
ファイル: wr.py プロジェクト: adervish/Ring-Builder
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
コード例 #15
0
def wheel():
    wheelSize = cmds.intSliderGrp('WheelSize', q=True, v=True)
    wheelThickness = cmds.intSliderGrp('WheelThickness', q=True, v=True)
    rgb = cmds.colorSliderGrp('WheelColour', q=True, rgbValue=True)
    global nextBlockId

    nsTmp = "Wheel" + str(nextBlockId)

    hubCap(nextBlockId, wheelSize, wheelThickness)

    createNamespace(nsTmp)

    wheelSizeY = wheelThickness * .1
    displaceY = (wheelThickness * .5) * .1
    for i in range(0, 2):
        #Create cylinder
        cmds.polyCylinder(r=wheelSize * 0.3, h=wheelSizeY, sa=50)
        facetCount = cmds.polyEvaluate(nsTmp + ":pCylinder1", face=True)
        cmds.move((-1 * ((wheelSizeY) / 2)),
                  nsTmp + ":pCylinder1.scalePivot",
                  nsTmp + ":pCylinder1.rotatePivot",
                  moveY=True,
                  os=True)
        cmds.move(displaceY, moveY=True)
        #eliminating the non-side Faces
        facetCount = facetCount - 2

        for j in range(0, facetCount):
            faceName = nsTmp + ":pCylinder1" + ".f[" + str(j) + "]"
            if j % 2 == 0:  #Extrudes every other face
                cmds.polyExtrudeFacet(faceName, ltz=((wheelSize * 0.1) / 4))

        cmds.rename("wheel1")

    cmds.select(nsTmp + ":wheel2")
    cmds.rotate(7.25, rotateY=True)
    cmds.move(((wheelThickness * .5) * .3), moveY=True)

    BOOLEAN(nsTmp, ":wheel1", ":wheel2", 1, "wheel")
    punchHole((wheelSize * .175), (wheelSizeY * 7), 0, 0, 0, nsTmp, ":wheel",
              "wheel")

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

    cmds.select(nsTmp + ":wheel")
    cmds.rename(nsTmp)

    cmds.hyperShade(assign=(nsTmp + ":WheelColour"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)

    cmds.polyUnite(nsTmp, "Hub" + str(nextBlockId - 1))
    cmds.delete(ch=True)
    cmds.rename(nsTmp)
    cmds.xform(cp=True)
コード例 #16
0
 def createButton(self):
     name = 'bu' + str(self.num_bu)
     cmds.polyCylinder(n=name, sx=8, sy=2, sz=3, h=.2)
     cmds.move(0, 0.144676, 0, name + '.e[40:47]', relative=True)
     cmds.move(0, 0.246665, 0, name + '.e[48:55]', relative=True)
     cmds.move(0, 0.290494, 0, name + '.vtx[57]', relative=True)
     self.num_bu += 1
     return name
コード例 #17
0
ファイル: crystalLattice.py プロジェクト: julae/maya-crystals
def diamondLattice(dimX=1, dimY=1, dimZ=1, radiusBall = 0.1, radiusStick = 0.02, latticeConst = 1.0, sticks = True):
  
    for x in xrange (0, dimX + 1):
        for y in xrange (0, dimY + 1):
            for z in xrange (0, dimZ + 1):

                scBalls(x, y, z, radiusBall, latticeConst)
                
                #coordinates for translation of spheres to lattice points
                xCoord = x * latticeConst
                yCoord = y * latticeConst
                zCoord = z * latticeConst
                
                xCoordFace = (x + 0.5) * latticeConst
                yCoordFace = (y + 0.5) * latticeConst
                zCoordFace = (z + 0.5) * latticeConst
                
                xCoordDia25 = (x + 0.25) * latticeConst
                yCoordDia25 = (y + 0.25) * latticeConst
                zCoordDia25 = (z + 0.25) * latticeConst
                
                xCoordDia75 = (x + 0.75) * latticeConst
                yCoordDia75 = (y + 0.75) * latticeConst
                zCoordDia75 = (z + 0.75) * latticeConst

                faceTranslations = [(xCoordFace, yCoordFace, zCoord), (xCoord, yCoordFace, zCoordFace), (xCoordFace, yCoord, zCoordFace)]
                
                nameSuffix = str(x) + str(y) + str(z)
                suffixDimChar = ['x', 'y', 'z']

                #fcc atoms
                for i in xrange(0, 3):
                    if suffixDimChar[i] == 'x' and x != dimX and y!= dimY or suffixDimChar[i] == 'y' and z != dimZ and y != dimY or suffixDimChar[i] == 'z' and x != dimX and z!=dimZ:
                        #facecentered balls
                        nameFaceBall = 'faceBall' + suffixDimChar[i] + nameSuffix
                        cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameFaceBall)
                        cmds.setAttr(str(nameFaceBall)+'.translate', faceTranslations[i][0], faceTranslations[i][1], faceTranslations[i][2])
                

                diamondTranslations = [(xCoordDia25, yCoordDia25, zCoordDia25), (xCoordDia75, yCoordDia75, zCoordDia25), (xCoordDia25, yCoordDia75, zCoordDia75), (xCoordDia75, yCoordDia25, zCoordDia75)]
                
                for i in xrange(0, 4):
                    if x != dimX and y != dimY and z != dimZ:
                        # 1/4 balls
                        nameDiaBall = 'diaBall' + str(i) + nameSuffix
                        cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameDiaBall)
                        cmds.setAttr(str(nameDiaBall)+'.translate', diamondTranslations[i][0], diamondTranslations[i][1], diamondTranslations[i][2])
                        
                        # bonds between lattice points
                        if sticks == True:
                            axes = [(-1, -1, -1), (1, 1, -1), (-1, 1, 1), (1, -1, 1)]
                            heightDia = math.sqrt(3) * 0.25 * latticeConst
                        
                            for j in xrange(0, 4):
                                #diamond sticks                
                                nameDiaStick = 'diaStick' + str(i) + str(j) + '_' + nameSuffix
                                cmds.polyCylinder(r=radiusStick, h=heightDia, sx=5, n=nameDiaStick, axis=axes[i])
                                cmds.setAttr(str(nameDiaStick)+'.translate', diamondTranslations[j][0] + 0.125*axes[i][0], diamondTranslations[j][1] + 0.125*axes[i][1], diamondTranslations[j][2] + 0.125*axes[i][2])
コード例 #18
0
def punchHole(rad, height, rotX, posX, posY, NSTMP, obj1, name):
    #made the cylinder here instead
    cmds.polyCylinder(r=rad, h=height)
    cmds.move(posX, moveX=True, a=True)
    cmds.move(posY, moveY=True)
    cmds.rotate(rotX, rotateX=True)

    #punched the hole in the block and renamed it back to pCube1 so that it loop friendly
    BOOLEAN(NSTMP, obj1, ":pCylinder1", 2, name)
コード例 #19
0
def createGear():
    teeth = 16
    teethLength = 0.2

    # name
    nsTmp = "Gear" + str(rnd.randint(1000, 9999))
    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)
    # query colour from UI
    rgb = cmds.colorSliderGrp('gearColour', q=True, rgbValue=True)

    # base
    gear = cmds.polyCylinder(r=0.7, h=0.4, sx=32)

    # extrude teeth
    for i in range(31):
        if (i % 2 == 0):
            cmds.select(gear[0] + ".f[" + str(i) + "]")
            cmds.polyExtrudeFacet(ltz=0.1)
            cmds.polyExtrudeFacet(ltz=0.1)
            cmds.polyMoveFacet(lsx=0.5)

    # decor
    tmp = cmds.polyCylinder(r=0.6, h=0.2)
    cmds.move(0.2, moveY=True, a=True)
    gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False)
    tmp = cmds.polyCylinder(r=0.6, h=0.2)
    cmds.move(-0.2, moveY=True, a=True)
    gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False)
    # center
    cylind = cmds.polyCylinder(r=0.3, h=0.6)
    #create x shape
    x = cmds.polyCube(w=0.5, h=0.6, d=0.2)
    tmp = cmds.polyCube(w=0.2, h=0.6, d=0.5)
    #combine them
    x = cmds.polyCBoolOp(x, tmp, op=1)
    x2 = cmds.duplicate(x)
    # remove from center
    cylind = cmds.polyCBoolOp(cylind, x, op=2)
    # remove from base
    gear = cmds.polyCBoolOp(gear, x2, op=2)

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

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.move(0.3, moveY=True, a=True)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
コード例 #20
0
def slopedBlock():
    blockHeight = 3
    blockWidth = cmds.intSliderGrp('slopedWidth', q=True, v=True)
    blockDepth = cmds.intSliderGrp('slopedDepth', q=True, v=True)
    rgb = cmds.colorSliderGrp('slopedColour', q=True, rgbValue=True)

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

    cubeSizeX = blockWidth * 0.8
    cubeSizeZ = blockDepth * 0.8
    cubeSizeY = blockHeight * 0.32

    cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ, sz=blockDepth)
    cmds.move((cubeSizeY / 2.0), y=True, a=True)

    for i in range(blockWidth):
        cmds.polyCylinder(r=0.25, h=0.20)
        cmds.move((cubeSizeY + 0.10), moveY=True, a=True)
        cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True)
        cmds.move((0 - (cubeSizeZ / 2.0) + 0.4), moveZ=True)

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

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.delete(ch=True)
    cmds.hyperShade(assign=(nsTmp + ":blckMat"))

    cmds.select((nsTmp + ":" + nsTmp + ".e[1]"), r=True)
    cmds.move(0, -0.8, 0, r=True)
    if blockDepth == 4:
        tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[8]"), q=True, t=True)
        cmds.select((nsTmp + ":" + nsTmp + ".vtx[6]"), r=True)
        cmds.move(tV[0], tV[1], tV[2], a=True)

        tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[9]"), q=True, t=True)
        cmds.select((nsTmp + ":" + nsTmp + ".vtx[7]"), r=True)
        cmds.move(tV[0], tV[1], tV[2], a=True)

    if blockDepth >= 3:
        tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[6]"), q=True, t=True)
        cmds.select((nsTmp + ":" + nsTmp + ".vtx[4]"), r=True)
        cmds.move(tV[0], tV[1], tV[2], a=True)

        tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[7]"), q=True, t=True)
        cmds.select((nsTmp + ":" + nsTmp + ".vtx[5]"), r=True)
        cmds.move(tV[0], tV[1], tV[2], a=True)

    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
コード例 #21
0
def RandomCylinder():
    cmds.polyCylinder(h = random.randrange(1,50), r = random.randrange(1,50), sx=4, sy=4, sz=4)
    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(selection=True))
コード例 #22
0
ファイル: cityGen.py プロジェクト: i7677181/scripts
def trunk(_name, _height, _rgb):

    cmds.polyCylinder(name=_name, sx=8, sy=1, sz=2, h=_height)
    cmds.xform(_name, piv=[0, -(_height / 2.0), 0])
    cmds.move(0, _height / 2.0, 0, _name, r=True)
    cmds.scale(0.3, 1, 0.3, _name)

    cmds.select(all=True)

    cmds.polyColorPerVertex(r=0.3, g=0.2, b=0.2, a=1, colorDisplayOption=True)
コード例 #23
0
 def kmCylinder(self):
     mc.polyCylinder(r=10,
                     h=20,
                     sx=8,
                     sy=1,
                     sz=1,
                     ax=[0, 1, 0],
                     rcp=0,
                     cuv=3,
                     ch=1)
コード例 #24
0
def makeDisk():
    numSides = cmds.intSliderGrp('numSides', q=True, v=True)

    cmds.polyCylinder(sx=numSides)
    sel = cmds.ls(sl=True)
    cmds.select(sel[0] + ".f[" + str(numSides) + "]")  # Selecting cap
    maya.mel.eval('GrowPolygonSelectionRegion;')
    cmds.delete()  # Deleting all but one cap
    cmds.select(sel[0])
    cmds.xform(cp=True)
    cmds.move(rpr=True)  # Moving Centered disk to origin
コード例 #25
0
ファイル: hanoi.py プロジェクト: mainConfetti/hanoi
def makeRingList(num):    
    rings=[]
    cmds.polyCylinder(n="ring", h=0.2, r=0.5)
    cmds.move(-8,0.1,0, 'ring', a=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
    for i in range(0,num):
        v = cmds.duplicate("ring")
        rings.append(v[0])
       
    cmds.delete('ring')
    return rings
コード例 #26
0
def basicBlock():
    # query values from UI sliders
    height = cmds.intSliderGrp('height', q=True, v=True)
    width = cmds.intSliderGrp('blockWidth', q=True, v=True)
    length = cmds.intSliderGrp('blockLength', q=True, v=True)
    rgb = cmds.colorSliderGrp('blockColour', q=True, rgbValue=True)

    # name
    nsTmp = "Block" + str(rnd.randint(1000, 9999))

    cmds.select(clear=True)
    cmds.namespace(add=nsTmp)
    cmds.namespace(set=nsTmp)

    # define a cube's size
    cubeSizeX = width * 0.8
    cubeSizeZ = length * 0.8
    cubeSizeY = height * 0.32

    # create a cube
    cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ)

    # move block half size up on Y axis
    cmds.move((cubeSizeY / 2.0), moveY=True)

    # loop through width and length (in bumps)
    for i in range(width):
        for j in range(length):
            # create cylinder
            cmds.polyCylinder(r=0.25, h=0.20)
            # move it on Y axis
            cmds.move((cubeSizeY + 0.10), moveY=True, a=True)
            # move it on X axis
            cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4),
                      moveX=True,
                      a=True)
            # move it on Z axis
            cmds.move(((j * 0.8) - (cubeSizeZ / 2.0) + 0.4),
                      moveZ=True,
                      a=True)

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

    cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False)
    cmds.delete(ch=True)

    cmds.hyperShade(assign=(nsTmp + ":blckMat"))
    cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
コード例 #27
0
def bccLattice(dimX=1,
               dimY=1,
               dimZ=1,
               radiusBall=0.1,
               radiusStick=0.02,
               latticeConst=1.0,
               sticks=True):

    for x in xrange(0, dimX + 1):
        for y in xrange(0, dimY + 1):
            for z in xrange(0, dimZ + 1):
                xCoord = x * latticeConst
                yCoord = y * latticeConst
                zCoord = z * latticeConst
                nameSuffix = str(x) + str(y) + str(z)

                #scPart of bccLattice
                scBalls(x, y, z, radiusBall, latticeConst)
                if sticks == True:
                    scSticks(x, y, z, dimX, dimY, dimZ, radiusStick,
                             latticeConst)

                # ball in body

                if x != dimX and y != dimY and z != dimZ:
                    xCoordBody = xCoord + 0.5 * latticeConst
                    yCoordBody = yCoord + 0.5 * latticeConst
                    zCoordBody = zCoord + 0.5 * latticeConst

                    nameBallBody = 'ballBody' + nameSuffix
                    cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameBallBody)
                    cmds.setAttr(
                        str(nameBallBody) + '.translate', xCoordBody,
                        yCoordBody, zCoordBody)

                    #sticks in body
                    if sticks == True:
                        heightBC = latticeConst * math.sqrt(3)

                        axes = [(1, 1, 1), (1, 1, -1), (1, -1, -1),
                                (-1, 1, -1)]

                        for i in xrange(0, 4):
                            nameStickBody = 'stickBody' + nameSuffix + '_' + str(
                                i)

                            cmds.polyCylinder(r=radiusStick,
                                              h=heightBC,
                                              sx=5,
                                              n=nameStickBody,
                                              axis=axes[i])
                            cmds.setAttr(
                                str(nameStickBody) + '.translate', xCoordBody,
                                yCoordBody, zCoordBody)
コード例 #28
0
 def __draw_column(self, name):
     cmds.polyCylinder(name=name,
                       r=self.column_diameter / 2,
                       h=self.column_height,
                       sx=30,
                       sy=1,
                       sz=0,
                       ax=(0, 0, 0),
                       rcp=0,
                       cuv=3,
                       ch=1)
コード例 #29
0
    def actionCmd(self, *args):

        #create turntable
        mc.polyCylinder(h=0.223, r=6.44)
        #create lights
        self.light1 = mc.directionalLight()
        mc.xform(t=(2.265, 6.358, -6.81), ro=(-139.31, -12.398, 31.896))
        self.light2 = mc.directionalLight()
        mc.xform(t=(7.9, 7.7, 0), ro=(-71.7, 22.8, -41.0))
        self.light3 = mc.directionalLight()
        mc.xform(t=(-2.3, 7.1, 7.5), ro=(-43.9, -12.4, 31.9))

        self.animateCam()
コード例 #30
0
ファイル: hanoi.py プロジェクト: mainConfetti/hanoi
def newScene():

	cmds.polyPlane(n="floor", h=30, w=30, sx=1, sy=1)
	cmds.polyCylinder(n="src", h=5, r=0.2)
	cmds.move(0,2.5,0, 'src', a = True)
	cmds.duplicate("src", n="temp")
	cmds.duplicate("src", n="dest")
	cmds.move(-8,0,0, "src", r=True)
	cmds.move(8,0,0, "dest", r=True)
	assignNewMaterial('floorMaterial', [0.3, 0.2, 0], 'floor')
	assignNewMaterial('pegMaterial', [0,0,0], 'src')
	assignMaterial('pegMaterial', 'temp')
	assignMaterial('pegMaterial', 'dest')
コード例 #31
0
def RandomCylinder():
    cmds.polyCylinder(h=random.randrange(1, 50),
                      r=random.randrange(1, 50),
                      sx=4,
                      sy=4,
                      sz=4)
    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(selection=True))
コード例 #32
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)
コード例 #33
0
ファイル: park.py プロジェクト: hcbsundberg/City_Generator
def makeFountain():
    '''
    Creates a fountain.
    
    On exit: A fountain shaped polygonal object has been created, assigned a shader
             and is returned as a tuple with the object name and node name. The 
             procedure uses random numbers in order to create different looking fountains
             every time it is called.
    '''
    steps = random.randint(1,3)
    fountain = cmds.polyCylinder(name = "Fountain", h = 0.1)
    cmds.xform(fountain, translation = (0, 0.25, 0))
    cmds.select(fountain[0] + ".f[40:59]")
    for i in range(steps):
        scale_ = random.uniform(0.6, 0.95) 
        cmds.polyExtrudeFacet(scale = (scale_, scale_, scale_))
        translation = random.uniform(0.1, 0.6)
        cmds.polyExtrudeFacet(translate = (0, translation, 0))
    cmds.polyExtrudeFacet(scale = (0.9,0.9,0.9))
    cmds.polyExtrudeFacet(translate = (0, -0.3,0))
    scale_ = random.uniform(0.3,0.6)
    cmds.polyExtrudeFacet(scale = (scale_,scale_,scale_))
    translation = random.uniform(0.2,0.4)
    cmds.polyExtrudeFacet(translate = (0,translation,0))
    stepsUp = random.randint(1,3)
    for i in range(stepsUp):
        scale_ = random.uniform(0.4,0.9) 
        cmds.polyExtrudeFacet(scale = (scale_,scale_,scale_))
        translation = random.uniform(0.05,1)
        cmds.polyExtrudeFacet(translate = (0,translation,0))
    top = fountainTop(fountain) # Create a top for the fountain.
    fountain = cmds.polyUnite(top[0],fountain)
    cmds.sets(fountain[0], edit=True, forceElement="fountainMaterialGroup")
    return fountain
コード例 #34
0
def generateCollision(mode="sphere"):
    
    selected = cmds.ls(sl=True)
    
    if not selected:
        logging.error("Please Select Something")
        return
    
    xmin, ymin, zmin, xmax, ymax, zmax = cmds.xform(selected[0], q=True, bb=True) # give 6 values 
    
    width = abs(xmax - xmin)
    height = abs(ymax - ymin)
    depth = abs(zmax - zmin)
    
    name = selected[0] + "_COL" # new name
    
    if (mode == "box"):
        mesh = cmds.polyCube(w=width, h=height, d=depth, n=name)[0]
        
    if (mode == "sphere"):
        radius = max([width, height, depth])/2
        mesh = cmds.polySphere(r=radius, sx=10, sy=10,n=name)
        
    if (mode == "cylinder"):
        radius = max([width,depth])/2
        mesh = cmds.polyCylinder(r=radius, h=height, n=name, sc=1, sx=12, sy=1, sz=1)
    
    xPos = xmax - width/2
    yPos = ymax - height/2
    zPos = zmax - depth/2
    
    cmds.xform(mesh, ws=True, t=[xPos,yPos,zPos])
コード例 #35
0
def create_tire(name, width, radius, tx, ty, tz):
    # Create a cylinder that represents a tire.
    # Return the transform node name.
    tire = cmds.polyCylinder(r=width * 2, h=width, ax=(0, 0, 1), name=name)
    arPolyNoise(tire[0], random.uniform(0.05, 0.45))
    cmds.setAttr("{0}.translate".format(tire[0]), tx, ty, tz)
    return tire[0]
コード例 #36
0
ファイル: makeSnowflakes.py プロジェクト: philrouse/snowFX
def crystalise(base):
    '''
    Adds hexagonal crystals to a branch
    
    base : The branch to be crystallised
    
    A crystal is created by scaling the top and bottom rings of vertices of a 
    cylinder. The crystal is aligned to the base branch and scaled to match. 
    The crystal is duplicated, randomly distributed along the branch and scaled 
    relative to their positioning. The crystals are combined with the base branch 
    mesh and this object is returned.
    '''
    crystal=[cmds.polyCylinder(r=1,sx=6,sy=2)[0]]
    cmds.polySoftEdge(crystal[0], a=0)
    cmds.scale(0.6,0.3,0.6,crystal[0]+'.f[12:13]',r=1)
    [(tx,ty,tz)] = cmds.getAttr(base+'.translate')
    [(rx,ry,rz)] = cmds.getAttr(base+'.rotate')
    cmds.move(tx,ty,tz,crystal[0])
    cmds.rotate(rx,ry,rz,crystal[0])
    [x1,y1,z1,x2,y2,z2] = cmds.xform(base+'.vtx[0:1]',q=1,t=1,ws=1)
    baseScale = cmds.getAttr(base+'.scaleX')
    cmds.scale(0.5,0.2,0.5,crystal[0])
    length = ((x2-x1)**2+(z2-z1)**2)**0.5
    for i in range(0,6):
        crystal[len(crystal):]=[cmds.duplicate(crystal[0])[0]]
    for x in crystal:
        dist = (random.random())
        cmds.move(length*dist,0,0,x,os=1,r=1,wd=1)
        size = (1.5-dist)*(length/3)
        cmds.scale(size,size,size,x,r=1)
        cmds.rotate(0,30,0,x,r=1)
    crystal += [base]
    return combineParts(crystal,base)
コード例 #37
0
def createRoundedBlock( blockSizeX, blockSizeY, blockSizeZ, blockLength ):
    
    edgeCylinderL = cmds.polyCylinder ( h = blockSizeZ, r = blockSizeY/2 )
    cmds.rotate( 90, rotateX = True )
    cmds.move( ( -blockSizeX/2 ), moveX = True, a=True)
    
    edgeCylinderR = cmds.polyCylinder ( h = blockSizeZ, r = blockSizeY/2 )
    cmds.rotate( 90, rotateX = True )
    cmds.move( ( blockSizeX/2 ), moveX = True, a=True)
    
    block = cmds.polyCube ( h = blockSizeY, w = blockSizeX, d = blockSizeZ, sx = ( blockLength - 1 ) * 2, sy = 2 )
    
    block =  cmds.polyCBoolOp( block, edgeCylinderL, op = 1 )
    block =  cmds.polyCBoolOp( block, edgeCylinderR, op = 1 )
    
    return block
コード例 #38
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)
コード例 #39
0
ファイル: park.py プロジェクト: hcbsundberg/City_Generator
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
コード例 #40
0
def SquareBlock():
     
    components = []
     
    # Fetching slider data
    blockDepth = cmds.intSliderGrp('SquareBlockDepth', query=True, value=True)
    blockWidth = cmds.intSliderGrp('SquareBlockWidth', query=True, value=True)
    rgb = cmds.colorSliderGrp('SquareBlockColour', query=True, rgbValue=True) 
     
    cmds.select(clear=True) 
     
    # Set to the lego size presets
    cubeDimX = blockWidth * 0.8
    blockHeight = 1
    cubeDimY = blockHeight * 0.32
    cubeDimZ = blockDepth * 0.8
     
    cube = cmds.polyCube(h=cubeDimY, w=cubeDimX, d=cubeDimZ, ch=False) 
    cmds.move((cubeDimY/2.0), moveY=True) 
     
    # Constructing the bumps
    for i in range(blockWidth): 
        for j in range(blockDepth):
            topBump = cmds.polyCylinder(r=0.25, h=0.20, ch=False) 
            components.append(topBump[0])
            cmds.move((cubeDimY + 0.10), moveY=True, a=True)
            cmds.move(((i * 0.8) - (cubeDimX/2.0) + 0.4), moveX=True, a=True)
            cmds.move(((j * 0.8) - (cubeDimZ/2.0) + 0.4), moveZ=True, a=True)
             
     
    finalShape =  cmds.polyUnite( cube[0], components, ch=False)
     
     
    # Adding on the colour
    shadedShape = addShader(finalShape, rgb)
def createABranch(rotAxis, angle):
    global prevRot,prevPos
    '''Extract Euler angles from constructed quaternion'''
    euAngles=EulerAnglesFromAxisQuat(rotAxis, angle)
    
    #print toDegrees(euAngles[0])#x
    #print toDegrees(euAngles[1])#y 
    #print toDegrees(euAngles[2])#z
            
    '''Create Cylinder'''
    if firsttime == True:
    	firsttime=False
    	branch = mc.polyCylinder(n='cy1',  r=0.1, height=branchLength)#axis=(dirx[0],diry[0],dirz[0]),
    	prevCylinder=branch
   	else:
		topPrevCylinderV1= cmds.xform(prevCylinder[0]+'.vtx[24]', translation=True, query=True)
		topPrevCylinderV2= cmds.xform(prevCylinder[0]+'.vtx[34]', translation=True, query=True)
		topfaceMidleX=(topPrevCylinderV1[0]+topPrevCylinderV2[0]) /2
		topfaceMidleY=(topPrevCylinderV1[1]+topPrevCylinderV2[1]) /2
		topfaceMidleZ=(topPrevCylinderV1[2]+topPrevCylinderV2[2]) /2
   		
		mycurve=cmds.curve( p=[(topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX+1, topfaceMidleY+1, topfaceMidleZ+1)] )
		cmds.select(prevCylinder[0]+'.f[21]')
		cmds.select(mycurve, add=True)
		cmds.polyExtrudeFacet(constructionHistory=1, keepFacesTogether=1, pvx= -1.11758709e-08, pvy=0.5, pvz= -1.490116119e-08, divisions=10 ,twist=0, taper=1, off=0, thickness=0, smoothingAngle=30, inputCurve=mycurve)
コード例 #42
0
  def generate(cls, *args):
    components = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    height = cmds.intSliderGrp(cls.get_prefix() + Labels["height_label"], query=True, value=True)
    depth = cmds.intSliderGrp(cls.get_prefix() + Labels["depth_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = height * Constants["block_height_unit"]
    block_depth = depth * Constants["block_depth_unit"]

    #stubs
    for x in range(0, width):
      for z in range(0, depth):
        stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"])
        components.append(stub[0])
        cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) * height + half(Constants["stub_height"]), Constants["block_depth_unit"] * z + half(Constants["block_depth_unit"]), stub[0])

    cube = cmds.polyCube(name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(depth * Constants["block_depth_unit"]), cube)
    if components.count > 1:
      final = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    else:
      final = components[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(final[0], r=True)
    cmds.hyperShade(assign=shader)
コード例 #43
0
    def createObjects(self, mode, numObjects, *args):
        """
        This creates objects. Support Cubes, Spheres, Cylinders and Cones
        :param mode: To create objects
        :param numObjects: Number of objects will be created
        :return: a list of created objects
        """

        objList = []

        for n in range(numObjects):
            if mode == 'Cube':
                obj = cmds.polyCube()
            elif mode == 'Sphere':
                obj = cmds.polySphere()
            elif mode == 'Cone':
                obj = cmds.polyCone()
            elif mode == 'Cylinder':
                obj = cmds.polyCylinder()
            else:
                cmds.error("I dont know what to create")

            objList.append(obj[0])

        cmds.select(objList)
コード例 #44
0
ファイル: park.py プロジェクト: hcbsundberg/City_Generator
def makeTree(shaders):
    '''
    Creates a tree.
    
    shaders: A list of shaders for the tree crown.
    On exit: A tree has been modeled, and is returned as a tuple 
             containing the object name and the node name. Some of the
             variables are chosen randomly to create different results.
    '''
    height = random.uniform(0.3,1.5)
    trunk = cmds.polyCylinder(name = "trunk", h = height, r = 0.07)
    cmds.sets(trunk[0], edit=True, forceElement="trunkMaterialGroup")
    cmds.xform(trunk, translation = (0,height/2.0 + 0.2,0))
    crown = cmds.polySphere(name = "crown", r = 0.5)
    cmds.xform(crown, translation = (0,height + 0.6,0))
    cmds.softSelect(sse = True, ssd = 0.86)
    cmds.select(crown[0] + ".vtx[381]")
    translation = random.uniform(0.3,1.5)
    cmds.move(translation, y = True, r = True)
    cmds.softSelect(sse = False)
    shader = random.choice(shaders)
    scale_ = random.uniform(0.7,1.8)
    cmds.select(crown)
    cmds.scale(scale_, scale_, scale_, pivot = (0,height,0))
    cmds.sets(crown[0], edit=True, forceElement= shader[1])
    tree = cmds.polyUnite(trunk[0],crown[0])
    cmds.delete(tree[0], ch = True)
    return tree
コード例 #45
0
def create_cylinder():
    result = cmds.polyCylinder(name='cylinder',
                               r=1.15,
                               h=0.15,
                               sx=6,
                               sy=1,
                               sz=1,
                               ax=(0, 1, 0),
                               rcp=0,
                               cuv=3,
                               ch=1)
    cmds.polyBevel3(result[0],
                    fraction=0.5,
                    offsetAsFraction=1,
                    autoFit=1,
                    depth=1,
                    mitering=0,
                    miterAlong=0,
                    chamfer=1,
                    segments=1,
                    worldSpace=1,
                    smoothingAngle=30,
                    subdivideNgons=1,
                    mergeVertices=1,
                    mergeVertexTolerance=0.0001,
                    miteringAngle=180,
                    angleTolerance=180,
                    ch=1)
    #print 'result: %s' % result
    return result
コード例 #46
0
ファイル: noise_car.py プロジェクト: Sbrophy923/ga306
def create_tire(name, width, radius, tx, ty, tz):
    # Create a cylinder that represents a tire.
    # Return the transform node name.
    tire = cmds.polyCylinder(h=width, r=radius, ax=(0,0,1), sc=True, name=name)
    cmds.setAttr("{0}.translate".format(tire[0]), tx, ty, tz)
    arPolyNoise(tire[0], 0.4)
    return tire[0]
コード例 #47
0
def pieslice(pStAn, pEnAn, pR, pH=0.1):
    cyl = mc.polyCylinder(h=pH, r=pR)
    cx = mc.objectCenter(x=True)
    cy = mc.objectCenter(y=True)
    cz = mc.objectCenter(z=True)

    h = pH
    #cut the cylinder, and separate different parts
    cut = mc.polyCut(cyl,
                     cutPlaneCenter=[cx, h / 2, cz],
                     cutPlaneRotate=[0, pStAn, 0],
                     extractFaces=True,
                     extractOffset=[0, 0, 0])
    cut = mc.polyCut(cyl,
                     cutPlaneCenter=[cx, h / 2, cz],
                     cutPlaneRotate=[0, pEnAn, 0],
                     extractFaces=True,
                     extractOffset=[0, 0, 0])
    obj = mc.polySeparate(cyl)
    names = []
    for i in range(len(obj)):
        mc.rename(obj[i], 'part' + str(i))
        names.append('part' + str(i))

    #delete useless parts from the now separated cylinder
    mc.delete(names[0:2] + names[3:], s=True)
    #fill hole of the leftover pieslice
    mc.polyCloseBorder(names[2])
    #add and assign a material (which was deleted when delete was called)
    myBlinn = mc.shadingNode('blinn', asShader=True)
    mc.select(names[2])
    mc.hyperShade(assign=myBlinn)
    return names[2]
コード例 #48
0
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 )
コード例 #49
0
def createBlockHoles( blockSizeX, blockSizeY, block, blockLength, blockOffset ):
    
    hcList = []
    rcyList = []
    rcuList = []
    
    for j in range( blockLength ):
        #create cylinders to cut holes
        holeCylinder = cmds.polyCylinder( r = 0.24, h = 2, sz=1 )
        cmds.rotate( 90, rotateX = True )
        cmds.move((blockSizeY/2), moveY = True, a = True)
        cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX = True, a = True)
        hcList.append( holeCylinder )
        
        #create cylinders to cut sunken area around holes 
        ##create a cylinder
        ridgeCylinder = cmds.polyCylinder( r=0.31, h=2, sz=1 )
        cmds.rotate( 90, rotateX = True )
        cmds.move((blockSizeY/2), moveY = True, a = True)
        cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX = True, a = True)
        rcyList.append( ridgeCylinder )
        
        ##create a cube
        ridgeCube = cmds.polyCube ( h = 0.64, w = blockSizeY, d = blockSizeY )
        cmds.rotate( 90, rotateX = True )
        cmds.move((blockSizeY/2), moveY=True )
        cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX=True )
        rcuList.append( ridgeCube )
    
    if len( hcList ) > 1 :
        holeCylinders = cmds.polyUnite( *hcList )  
        ridgeCylinders = cmds.polyUnite( *rcyList )
        ridgeCubes = cmds.polyUnite( *rcuList )  
    else:
        holeCylinders = hcList[0]
        ridgeCylinders = rcyList[0]
        ridgeCubes = rcuList[0]
        
    block = cmds.polyCBoolOp( block, holeCylinders, op=2 )
    
    ridgeCutter = cmds.polyCBoolOp( ridgeCylinders, ridgeCubes, op=2 ) 
    
    block = cmds.polyCBoolOp( block, ridgeCutter, op=2 )
    
    return block
コード例 #50
0
  def generate(cls, *args):
    components = []
    boolean = []
    width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
    rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)

    block_width = width * Constants["block_width_unit"]
    block_height = Constants["block_height_unit"]
    block_depth = Constants["block_depth_unit"]

    for x in range(0, width + 1):
      hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
      boolean.append(hole[0])
      cmds.rotate('90deg', 0, 0, hole[0])
      cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0])

    cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
    components.append(cube[0])
    cmds.delete(cube[0] + ".f[40:47]")
    cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)

    #caps
    cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap"))
    cmds.rotate('90deg',0,0,cap_one[0])
    cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0])
    cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]")
    components.append(cap_one[0])

    #caps
    cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"])
    cmds.rotate('90deg','180deg',0,cap_two[0])
    cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]")
    cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0])
    components.append(cap_two[0])

    solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
    boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
    cmds.polyMergeVertex( solid[0], d=0.15 )
    cmds.delete(solid[0],ch=1)
    final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )

    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(final[0], r=True)
    cmds.hyperShade(assign=shader)
コード例 #51
0
    def __init__(self, name, r=1.0, h=6.0, x=0.0, y=0.0, z=0.0):
        self._name = name
        self.force = 4.0
        self.direction = V(0.0, 1.0, 0.0)
        if cmds.objExists(name):
            self.position = V(cmds.getAttr("{0}.translate".format(name))[0])
            obstacleScale = cmds.getAttr("{0}.scale".format(name))[0]
            self.radius = cmds.polyCylinder(name, query=True, radius=True) * obstacleScale[0] + 1.0
            self.height = cmds.polyCylinder(name, query=True, height=True) * obstacleScale[1]
        else:
            print 'box with name "{0}" does not exist'.format(name)
            self.radius = r
            self.height = h
            self.position = V(x, y, z)

        print "reload"
        print self.position
        print self.height
コード例 #52
0
ファイル: bits.py プロジェクト: EriLee/marigold
def hingeY( inBitName ):
    bit = cmds.polyCylinder( axis=[0,1,0],
                               radius=1,
                               height=10,
                               subdivisionsX=6,
                               subdivisionsY=1,
                               subdivisionsZ=1,
                               name=inBitName )
    # Return the name of the newly created bit.
    return bit[0]
コード例 #53
0
ファイル: jimboBalloon.py プロジェクト: radvfx/py
def tieOff():
	global balloonRadius, balloonQuantity
	knotVals = mc.pointPosition('balloonTemp.vtx[96]', w=True)
	knotThickness = balloonRadius * .05
	endHeight = balloonRadius * .15
	knotRadius = knotVals[0]
	knotPos = ( knotVals[1] - (.5 * knotThickness))

	mc.polyCylinder( n="knotTemp", r=knotRadius, h=knotThickness, sx=12, sy=3, sz=0, rcp=0, cuv=3)
	mc.delete( 'knotTemp.f[36:37]')
	mc.setAttr( 'knotTemp.translateY', knotPos )
	mc.scale(1.25, 1.75, 1.25, 'knotTemp.vtx[12:35]', r=True )
	mc.lattice( n='knot', cp=True,  dv =(2, 2, 2), objectCentered=True, ldv=(2,2,2))
	mc.move( (.75 * knotThickness), 'knotLattice.pt[1][0][0:1]', r=True, y=True)
	mc.move( (.25 * knotThickness), 'knotLattice.pt[0][0][0:1]', r=True, y=True)

	mc.duplicate('knotTemp')
	mc.rotate(180, 'knotTemp1', z=True)

	mc.polyCone( n="endTemp", r=knotRadius*2, h=endHeight, sx=12, sy=6, sz=3, rcp=0, cuv=3)
	mc.delete( 'endTemp.f[60:83]', 'endTemp.f[96:107]')
	mc.setAttr( 'endTemp.translateY', knotPos - knotThickness/2 )	
	mc.scale( 1.15, 1, 1.15, 'endTemp.vtx[36:59]') 
	mc.move((.5 * endHeight), 'endTemp.vtx[0:11]', 'endTemp.vtx[72]', y=True, r=True)
	mc.polyUnite( 'balloonTemp', 'knotTemp', 'knotTemp1', 'endTemp', ch=True )
	mc.polySoftEdge( a = 180 )
	mc.polyMergeVertex( d=.001)

	mc.polyEditUV('polySurface1.map[0:126]', pu=0.5, pv=1, su=1, sv=0.575)
	mc.polyEditUV('polySurface1.map[127:230]', pu=0.5, pv=0.35, su=2, sv=.25)
	mc.polyEditUV('polySurface1.map[267:318]', u=0, v=-0.1, pu=0.5, pv=0, su=1, sv=.5)
	mc.polyEditUV('polySurface1.map[231:266]', 'polySurface1.map[319]', u=0, v=-.175, pu=0.5, pv=0.25, su=0.25, sv=0.25)
	mc.polyMergeUV('polySurface1.map[103:126]', d=0.5, ch=True )
	mc.polyEditUV('polySurface1.map[104]',  r=False, u=0)
	mc.polyEditUV('polySurface1.map[103]', r=False, u=1)
	mc.polySmooth('polySurface1',  mth=0, dv=1, c=1, kb=0, ksb=1, khe=0, kt=1, kmb=0, suv=0, peh=0, sl=1, dpe=1, ps=0.1 , ro=1, ch=True)

	mc.DeleteHistory()
	mc.delete( 'knotTemp1')
	mc.rename('polySurface1', 'balloon1')
	mc.select(cl=True)
	return
コード例 #54
0
ファイル: crane.py プロジェクト: chirs/studio5
def make_arm():
    """
    Crane arm
    """

    a1l = cmds.polyCube(w=1.5, h=4, d=.2, name="arm1_left")
    cmds.move(0, 0, -.25, a1l)

    a1r = cmds.polyCube(w=1.5, h=4, d=.2, name="arm1_right")
    cmds.move(0, 0, .25, a1r)

    a2 = cmds.polyCube(w=1, h=8, d=.2, name="arm2")
    cmds.move(0, 4, 0, a2)


    a3l = cmds.polyCube(w=1, h=6, d=.2, name="arm3_left")
    cmds.move(0, 8, .25, a3l)

    a3r = cmds.polyCube(w=1, h=6, d=.2, name="arm3_right")
    cmds.move(0, 8, -.25, a3r)

    a4 = cmds.polyCube(w=1, h=4, d=.2, name="arm4")
    cmds.move(0, 12, 0, a4)

    pin1 = cmds.polyCylinder(axis=(0,0,1), h=1.5,radius=.3, name="pin1")
    cmds.move(0, -1.25, 0, pin1)

    pin2 = cmds.polyCylinder(axis=(0,0,1), h=1.5,radius=.3, name="pin2")
    cmds.move(0, 1.5, 0, pin2)

    pin3 = cmds.polyCylinder(axis=(0,0,1), h=1.5,radius=.3, name="pin3")
    cmds.move(0, 5.5, 0, pin3)

    pin4 = cmds.polyCylinder(axis=(0,0,1), h=1.5,radius=.3, name="pin4")
    cmds.move(0, 10.5, 0, pin4)

    l = [a1l,a1r,a2,a3l,a3r,a4,pin1,pin2,pin3,pin4]
    g = cmds.group(*l, name='g1')

    cmds.move(0,4.5,0,g)

    return g
コード例 #55
0
ファイル: crystalLattice.py プロジェクト: julae/maya-crystals
def fccLattice( dimX=1, dimY=1, dimZ=1, radiusBall = 0.1, radiusStick = 0.02, latticeConst = 1.0, sticks = True ):
    
    for x in xrange (0, dimX + 1):
        for y in xrange (0, dimY + 1):
            for z in xrange (0, dimZ + 1):
                xCoord = x * latticeConst
                yCoord = y * latticeConst
                zCoord = z * latticeConst
                nameSuffix = str(x) + str(y) + str(z)
                
                scBalls(x, y, z, radiusBall, latticeConst)
                if sticks == True:
                    scSticks(x, y, z, dimX, dimY, dimZ, radiusStick, latticeConst)
                
                heightFCC = math.sqrt(2) * latticeConst
                xCoordFace = (0.5+x)*latticeConst
                yCoordFace = (0.5+y)*latticeConst
                zCoordFace = (0.5+z)*latticeConst
                
                faceTranslations = [(xCoordFace, yCoordFace, zCoord), (xCoord, yCoordFace, zCoordFace), (xCoordFace, yCoord, zCoordFace)]
                suffixDimChar = ['x', 'y', 'z']
                axes = [(1, 1, 0), (0, 1, 1), (1, 0, 1)]
                axesNeg = [(1, -1, 0), (0, -1, 1), (-1, 0, 1)]

                
                for i in xrange(0, 3):
                    if suffixDimChar[i] == 'x' and x != dimX and y!= dimY or suffixDimChar[i] == 'y' and z != dimZ and y != dimY or suffixDimChar[i] == 'z' and x != dimX and z!=dimZ:
                        #facecentered balls
                        nameFaceBall = 'faceBall' + suffixDimChar[i] + nameSuffix
                        cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameFaceBall)
                        cmds.setAttr(str(nameFaceBall)+'.translate', faceTranslations[i][0], faceTranslations[i][1], faceTranslations[i][2])
                        
                        #sticks to face centered balls
                        if sticks == True:
                            nameFaceStick1 = 'faceStick1_' + suffixDimChar[i] + nameSuffix
                            cmds.polyCylinder(r=radiusStick, h=heightFCC, sx=5, n=nameFaceStick1, axis=axes[i])
                            cmds.setAttr(str(nameFaceStick1)+'.translate', faceTranslations[i][0], faceTranslations[i][1], faceTranslations[i][2])

                            nameFaceStick2 = 'faceStick2_' + suffixDimChar[i] + nameSuffix
                            cmds.polyCylinder(r=radiusStick, h=heightFCC, sx=5, n=nameFaceStick2, axis=axesNeg[i])
                            cmds.setAttr(str(nameFaceStick2)+'.translate', faceTranslations[i][0], faceTranslations[i][1], faceTranslations[i][2])
コード例 #56
0
ファイル: honeycomb.py プロジェクト: philiply/MayaScripts
def honeycomb(xbound, zbound, flat, buildCity):
	dx = 0
	indentOn = False #start 0.867 ahead
	cellnum = 0
	while (dx < xbound):
		dz = 0
		if(indentOn):
			dz = 0.867
		while (dz < zbound):
			cellname = "cell" + "%04d"%cellnum
			randomheight = 0
			raiseMe = False
			if not flat:
				randomheight = .1 - (0.2 * random.random())
			if buildCity:
				if xbound/2 - xbound/10 < dx and dx < xbound/2 + xbound/10 and zbound/2 - zbound/10 < dz and dz < zbound/2 + zbound/10:
					raiseMe = True
					randombuildingheight = 20 - (10 * random.random())
				
			cmds.polyCylinder(name = cellname, ax=[0,1,0], radius=1, height=1, sx=6, sy=1, sz=0)
			if raiseMe:
				cmds.move(0, randombuildingheight, 0, cellname+'.f[7]', r=True)
			else:
				cmds.move(0, randomheight, 0, cellname+'.f[7]', r=True)
			cmds.polyExtrudeFacet(cellname+'.f[7]', kft=False, s=(0.896415,0.896415,0.896415), divisions = 3)
			cmds.polyExtrudeFacet(cellname+'.f[7]', kft=False, ty=-0.15636, divisions=3)
			cmds.select(cellname)
			cmds.polyBevel(offset = 0.7, offsetAsFraction = 1, autoFit = 1, segments = 1, worldSpace = 1, uvAssignment = 0, fillNgons = 1, mergeVertices = 1, mergeVertexTolerance = 0.0001,  miteringAngle = 180, angleTolerance = 180, ch = 1)

			cmds.move(dx, 0, dz)
			
			print "cylinder " + cellname + " location = dx: " + str(dx) + ", dz: " + str(dz)
			
			dz+=1.729
			cellnum += 1
		dx += 1.5
		indentOn = not indentOn
		
	cmds.select([node for node in cmds.ls() if 'cell' in node and 'Shape' not in node])
	cmds.group(name='honeycomb')
	cmds.move(-xbound/2, 0, -zbound/2, 'honeycomb')
コード例 #57
0
ファイル: toh.py プロジェクト: docwhite/TowersOfHanoi
def placeDisks( pDiskNumUIField, *Args ):
    """
    Will place the initial disks into the peg A. But it will check if there are any before, in case 
    that there were some, it will delete them (calling the clearTowers procedure). The created ob-
    jects will be placed in the pegA list, so that we can access each disk using [] (pegA[0] would
    be the bottom larger peg[1] the one one step above, until the last one peg[n] being the smallest
    and highest one. I give an example about what the pegA list would look like if we had 3 disks: 
          pegA[0] (1st element) will be called 'disk3'
          pegA[1] (2nd element) will be called 'disk2'
          pegA[2] (3rd element) will be called 'disk1'
    """

    # Creates board and pegs with their relative materials. This just runs the first time the code is executed.
    
    if not board: # If board exists.
        tableSetup() 

    nDisks = cmds.intSliderGrp( diskNumUIField, q=True, v=True )
        
    if len(pegA) != 0:
        cmds.text( warnings, e=True, bgc=(0.85,0,0) )
        cmds.text( warnings, e=True, l="Please, first press 'CLEAR ALL', thanks." )
    else:
        cmds.text( warnings, e=True, bgc=(0,0.66,0.05) )
        cmds.text( warnings, e=True, l="None." )
        j = nDisks
        it = 0
        while j > 0:
            # Records the disks to the pegA list. Will look like disk3 (bottom/largest) disk2 (middle/medium), 
            # disk1 (top/smallest)"...
            disk = cmds.polyCylinder( n='disk'+`j`, h=0.2, r=1.5-(0.1*it) )[0]
            pegA.append(disk)
            cmds.xform( t=pLeft )
            cmds.xform( t=[0,0.6+(nDisks-j)*0.2,0], r=True )
            
            # Apply the materials to the disks
            import materials
            reload(materials)
            colourArrayDisks = cmds.colorSliderGrp( 'rgb_disks', q=True, rgb=True)
            shadingObjs = materials.applyShaderDisk( disk, colourArrayDisks )
            global superList
            superList += shadingObjs[0], shadingObjs[1]
            print shadingObjs[0], shadingObjs[1],"(374) have been added to superList. Now superList contains:", superList

            print pegA[it], "has been created and placed in pegA"
            
            # Set the keyframe
            global KFTime
            anim.setKeyframeToDisk( pegA[it], KFTime )
            it = it + 1
            j = j - 1
                
        print "The pegA list contains: ", pegA
コード例 #58
0
ファイル: felix.py プロジェクト: quentinjcm/musiclinker
def createSpeaker():
    """create a speaker shape to be used as a sound visualiser.
	
	return : name of the cylinder created
	"""
    # create cylinder
    speaker = cmds.polyCylinder(h=0.025, r=0.5)
    # extrude to create 'speaker' shape
    cmds.polyExtrudeFacet(speaker[0] + ".f[21]", scale=(0.8, 0.8, 0.8))
    cmds.polyExtrudeFacet(speaker[0] + ".f[21]", scale=(0.5, 0.5, 0.5), translate=(0, -0.2, 0))
    cmds.polyExtrudeFacet(speaker[0] + ".f[21]", translate=(0, 0.1, 0))
    return speaker
コード例 #59
0
def tree():
    treeTrunk = mc.polyCylinder( r=0, h=6, sx=8, n="Tree_Trunk" )
    mc.move( 0,6/2.4,0, treeTrunk )
    
    treeBody = mc.polySphere( r=3, sx=8, sy=8, n="Tree_Body" )
    mc.move( 0,8,0, treeBody ) 
    
    mc.scale( 1,2,1, treeBody )
    mc.select( treeTrunk, treeBody )
    mc.group( n="Tree Group" )

# -------------------------------------------------------------->