Beispiel #1
0
 def birth(self, mom):
    x=2
    cmds.polyCube(n=self.name, w=0, h=0, d=0)
    cmds.scale(self.size-x,self.size-x,self.size-x, absolute = True)       
    p=cmds.pointConstraint(mom, self.name)
    cmds.delete(p)
    cmds.parent(self.name, mom)
Beispiel #2
0
	def placeBlock(self, *args) :
		cmds.polyCube(w=1,h=1)
		name=cmds.ls(sl=True)
		w=cmds.floatFieldGrp('dim',query=True, value1=True)
		h=cmds.floatFieldGrp('dim',query=True, value2=True)

		cmds.setAttr('%s.scaleX' %(name[0]),w/2.0)
		cmds.setAttr('%s.scaleY' %(name[0]),h/2.0)

		r=cmds.floatFieldGrp('rotation',query=True, value1=True)
		cmds.addAttr(name[0],ln='BodyType', dt='string')
		bt=cmds.optionMenuGrp("bodyType", query=True ,value=True)
		cmds.setAttr('%s.BodyType' %(name[0]),bt ,type='string')


		cmds.addAttr(name[0],ln='friction')
		f=cmds.floatFieldGrp('friction',query=True, value1=True)
		cmds.setAttr('%s.friction' %(name[0]),f)

		cmds.addAttr(name[0],ln='restitution')
		r=cmds.floatFieldGrp('restitution',query=True, value1=True)
		cmds.setAttr('%s.restitution' %(name[0]),r)

		cmds.addAttr(name[0],ln='density')
		d=cmds.floatFieldGrp('density',query=True, value1=True)
		cmds.setAttr('%s.density' %(name[0]),d)

		r=cmds.floatFieldGrp('rotation',query=True, value1=True)
		cmds.setAttr('%s.rotateZ' %(name[0]),r)
    def testExportToAnonymousLayer(self):
        """
        Tests exporting to an existing anonymous layer. In normal (non-append)
        mode, this should completely overwrite the contents of the anonymous
        layer.
        """
        cmds.file(new=True, force=True)
        cmds.polyCube(name='TestCube')

        stage = Usd.Stage.CreateInMemory()
        self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())

        cmds.usdExport(
                file=stage.GetRootLayer().identifier,
                mergeTransformAndShape=True,
                shadingMode='none')
        self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())

        cmds.rename('TestCube', 'TestThing')
        cmds.usdExport(
                file=stage.GetRootLayer().identifier,
                mergeTransformAndShape=True,
                shadingMode='none')
        self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
        self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
    def testExportToDiskLayer(self):
        """
        Tests that exporting to an on-disk layer that is open elsewhere in the
        process still works.
        """
        cmds.file(new=True, force=True)
        cmds.polyCube(name='TestCube')

        filePath = os.path.abspath("testStage.usda")
        stage = Usd.Stage.CreateNew(filePath)
        stage.Save()
        self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())

        cmds.usdExport(
                file=filePath,
                mergeTransformAndShape=True,
                shadingMode='none')
        self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())

        cmds.rename('TestCube', 'TestThing')
        cmds.usdExport(
                file=filePath,
                mergeTransformAndShape=True,
                shadingMode='none')
        self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
        self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
 def updateData(self, useRootOffsetData=False):
     if useRootOffsetData:
         #Take out offset
         useZ = cmds.checkBox(g_rootOffsetZBox, q=True, value=True)
         useY = cmds.checkBox(g_rootOffsetYBox, q=True, value=True)
         
         rootPosition = cmds.xform('Root', q=True, t=True)
         boxPosition = cmds.xform( self.m_name, q=True, t=True)
         
         #zero X because we don't care
         boxPosition[0] = 0
         if useZ and useY:
             #Both Axis offset
             boxPosition[1] = boxPosition[1] - rootPosition[1]
             boxPosition[2] = boxPosition[2] - rootPosition[2]
         elif useZ and not useY:
             boxPosition[2] = boxPosition[2] - rootPosition[2]
         elif not useZ and useY:
             boxPosition[1] = boxPosition[1] - boxPosition[1]
             
         self.m_position = boxPosition
         self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2]))
         self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True )
         self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2)
         self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2)
     else:
         self.m_position = cmds.xform( self.m_name, q=True, t=True ) #Finds the translation, we should probably be finding the point of hte bottom left corner?? 
         self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2]))
         self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True )
         self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2)
         self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2)
    def testAnimMeshReload(self):

        MayaCmds.polyCube( name = 'mesh')
        MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[1, 24])
        MayaCmds.setKeyframe('meshShape.vtx[0:7]')
        MayaCmds.currentTime(12, update=True)
        MayaCmds.select('meshShape.vtx[0:7]')
        MayaCmds.scale(5, 5, 5, r=True)
        MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[12])
        self.__files.append(util.expandFileName('testAnimMeshReadWrite.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root mesh -f ' + self.__files[-1])

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

        # save as a maya file
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # reload as a maya file
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        retVal = True
        mesh1 = '|mesh|meshShape'
        mesh2 = '|mesh1|meshShape'
        for t in range(1, 25):
            MayaCmds.currentTime(t, update=True)
            if not util.compareMesh( mesh1, mesh2 ):
                self.fail('%s and %s were not equal at frame %d' % (mesh1,
                    mesh2, t))
	def createCube(self, *args):
		
		i = 0
		j = 0
		k = 1
		posX = 0
		
		cubeStock = []
		dupCubeStock = []
		
		self.cubeNumX = self.numX_input()
		self.cubeNumZ = self.numZ_input()
				
		while i < self.cubeNumX :	
		
			cmds.polyCube( w = 10, h = 10, d = 10, sx = self.divX_input(), sy = self.divY_input(), sz = self.divZ_input(), ax = (0, 1, 0), cuv = 4, ch = 1)

			cmds.move(15 * i, 0, 0)
			
			self.cubeName = str(cmds.pickWalk(d = "up"))
			self.splittedCubeName = self.cubeName.split("'")[1]
			self.cubeFinalName = unicode(self.splittedCubeName)
			print("cubeFinalName : " + self.cubeFinalName)
			cubeStock.append(self.cubeFinalName)
			
			i += 1
			
		while j < self.cubeNumZ :			
			posX = cmds.getAttr(str(cubeStock[j]) + ".translateX")
			cmds.select(cubeStock[j], r = True)
			dup = cmds.duplicate(cubeStock[j])
			cmds.move(posX, 0, 15 * k)	
			j += 1
			k += 1
Beispiel #8
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
Beispiel #9
0
def make_shape(type, name, divisions):
    """
    Creates shape based on argument passed

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

    if type == 'cube':
        mc.polyCube(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cone':
        mc.polyCone(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cylinder':
        mc.polyCylinder(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'plane':
        mc.polyPlane(n=name, sx=divisions, sy=divisions)
    elif type == 'torus':
        mc.polyTorus(n=name, sx=divisions, sy=divisions)
    elif type == 'sphere':
        mc.polySphere(n=name, sx=divisions, sy=divisions)
    else:
        mc.polySphere()
def makeRobot():
    MayaCmds.polyCube(name="head")
    MayaCmds.move(0, 4, 0, r=1)

    MayaCmds.polyCube(name="chest")
    MayaCmds.scale(2, 2.5, 1)
    MayaCmds.move(0, 2, 0, r=1)
    MayaCmds.polyCube(name="leftArm")
    MayaCmds.move(0, 3, 0, r=1)
    MayaCmds.scale(2, 0.5, 1, r=1)
    MayaCmds.duplicate(name="rightArm")
    MayaCmds.select("leftArm")
    MayaCmds.move(1.25, 0, 0, r=1)
    MayaCmds.rotate(0, 0, 32, r=1, os=1)
    MayaCmds.select("rightArm")
    MayaCmds.move(-1.25, 0, 0, r=1)
    MayaCmds.rotate(0, 0, -32, r=1, os=1)
    MayaCmds.select("rightArm", "leftArm", "chest", r=1)
    MayaCmds.group(name="body")

    MayaCmds.polyCube(name="bottom")
    MayaCmds.scale(2, 0.5, 1)
    MayaCmds.move(0, 0.5, 0, r=1)
    MayaCmds.polyCube(name="leftLeg")
    MayaCmds.scale(0.65, 2.8, 1, r=1)
    MayaCmds.move(-0.5, -1, 0, r=1)
    MayaCmds.duplicate(name="rightLeg")
    MayaCmds.move(1, 0, 0, r=1)
    MayaCmds.select("rightLeg", "leftLeg", "bottom", r=1)
    MayaCmds.group(name="lower")

    MayaCmds.select("head", "body", "lower", r=1)
    MayaCmds.group(name="robot")
    def testExportWithClashStripping(self):
        mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
        cmds.file(mayaFilePath, new=True, force=True)

        node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
        cmds.namespace(add="foo")
        cmds.namespace(set="foo");
        node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
        cmds.namespace(set=":");

        usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')

        errorRegexp = "Multiple dag nodes map to the same prim path" \
            ".+|cube1 - |foo:cube1.*"
        with self.assertRaisesRegexp(RuntimeError, errorRegexp) as cm:
            cmds.usdExport(mergeTransformAndShape=True,
                           selection=False,
                           stripNamespaces=True,
                           file=usdFilePath,
                           shadingMode='none')

        with self.assertRaisesRegexp(RuntimeError,errorRegexp) as cm:
            cmds.usdExport(mergeTransformAndShape=False,
                           selection=False,
                           stripNamespaces=True,
                           file=usdFilePath,
                           shadingMode='none')
    def testExportWithStripAndMerge(self):
        mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
        cmds.file(mayaFilePath, new=True, force=True)

        cmds.namespace(add=":foo")
        cmds.namespace(add=":bar")

        node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
        cmds.namespace(set=":foo");
        node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube2" )
        cmds.namespace(set=":bar");
        node3 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube3" )
        cmds.namespace(set=":");

        usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')

        cmds.usdExport(mergeTransformAndShape=True,
                       selection=False,
                       stripNamespaces=True,
                       file=usdFilePath,
                       shadingMode='none')

        stage = Usd.Stage.Open(usdFilePath)
        self.assertTrue(stage)

        expectedPrims = ("/cube1", "/cube2", "/cube3")

        for primPath in expectedPrims:
            prim = stage.GetPrimAtPath(primPath)
            self.assertTrue(prim.IsValid(), "Expect " + primPath)
 def __init__(self, name_, height, width, depth, shader):
     '''
     Initializes a BoxHouse object, and creates a polygonal house object based on a
     box primitive.
     
     self: Object that is to be initialized.
     name_: name_: A string with the name the polygonal house object will have.
     height: The height of the house.
     width: The width of the house.
     depth: The depth of the house.
     shader: Shader that will be assigned to the house. 
     On exit: A BoxHouse object has been initialized and a polygonal house has 
              been created out of a box 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_, "box", height, width, depth)
     n = cmds.polyCube(n = "house_", w = width, h = height, d = depth, sy = height)
     cmds.xform(n[0], translation = (0, height/2.0, 0))
     f = cmds.polyCube(n = "foundation", w = width + 0.3, h = 0.8, d = depth + 0.3)
     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)
    def test_agst(self):

        # animated geometry, static transform node
        nodename = 'agst_node'
        MayaCmds.polyCube(name=nodename)
        MayaCmds.select(nodename+'.vtx[0:8]')
        MayaCmds.setKeyframe(time=1.0)
        MayaCmds.scale(1.5, 1.5, 1.8)
        MayaCmds.setKeyframe(time=5.0)

        self.__files.append(util.expandFileName('agst_motionblur_noSampleGeo_Test.abc'))
        MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -wfg -root %s -file %s' % (
            nodename, self.__files[-1]))

        # frameRange: 1, 2, 3, 4, 5, 6
        self.isFrameRangeTransAndFrameRangeShapeExists(self.__files[-1])

        self.__files.append(util.expandFileName('agst_motionblur_Test.abc'))
        MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -root %s -f %s' % (
            nodename, self.__files[-1]))

        # frameRange: 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6
        self.isFrameRangeExists(self.__files[-1])

        self.__files.append(util.expandFileName('agst_noSampleGeo_Test.abc'))
        MayaCmds.AbcExport(j='-fr 1 5 -wfg -root %s -f %s' % (nodename,
            self.__files[-1]))

        # frameRange: 1, 2, 3, 4, 5
        self.isFrameRangeExists(self.__files[-1])
    def testPolyUVs(self):
        MayaCmds.polyCube(name = 'cube')
        cubeObj = getObjFromName('cubeShape')
        fnMesh = OpenMaya.MFnMesh(cubeObj)

        # get the name of the current UV set
        uvSetName = fnMesh.currentUVSetName()

        uArray = OpenMaya.MFloatArray()
        vArray = OpenMaya.MFloatArray()
        fnMesh.getUVs(uArray, vArray, uvSetName)

        newUArray = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, -1, -1]
        newVArray = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 1 , 0,  1]
        for i in range(0, 14):
            uArray[i] = newUArray[i]
            vArray[i] = newVArray[i]
        fnMesh.setUVs(uArray, vArray, uvSetName)

        self.__files.append(util.expandFileName('polyUvsTest.abc'))
        MayaCmds.AbcExport(j='-uv -root cube -file ' + self.__files[-1])

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

        MayaCmds.select('cube.map[0:13]', replace=True)
        uvs = MayaCmds.polyEditUV(query=True)
        for i in range(0, 14):
            self.failUnlessAlmostEqual(newUArray[i], uvs[2*i], 4,
                'map[%d].u is not the same' % i)
            self.failUnlessAlmostEqual(newVArray[i], uvs[2*i+1], 4,
                'map[%d].v is not the same' % i)
Beispiel #16
0
	def HI(self):
            if self.checkSphere.isChecked():
                cmds.polySphere()
            if self.checkTorus.isChecked():
                cmds.polyTorus()
            if self.checkCube.isChecked():
                cmds.polyCube()
            pass
Beispiel #17
0
 def testStaticMeshPropReadWrite(self):
     nodeName = 'polyCube'
     shapeName = 'polyCubeShape'
     MayaCmds.polyCube(name=nodeName)
     self.setProps(shapeName)
     self.__files.append(util.expandFileName('staticPropMesh.abc'))
     MayaCmds.AbcExport(j='-atp SPT_ -root %s -f %s' % (nodeName, self.__files[-1]))
     self.verifyProps(shapeName, self.__files[-1])
Beispiel #18
0
def testBasicObjectSetMain():
	failures = 0

	# Test #1
	#
	# - Create a sphere and a cube.
	# - Create a custom MPxObjectSet and add the sphere and cube to the set.
	# - Delete the sphere.
	# - Ensure the set is still present.
	# - Delete the cube.
	# - Ensure the set is deleted.
	#
	cmds.file(f=True, new=True)
	sphere = cmds.polySphere(r=1, sx=20, sy=20, ax=(0, 1, 0), tx=1, ch=1)
	cube = cmds.polyCube(w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 1, 0), tx=1, ch=1)
	cmds.select(sphere[0], cube[0])
	objSet = maya.mel.eval("spBasicObjectSetTest")

	cmds.delete(sphere[0])
	if not cmds.objExists(objSet):
		failures += 1

	cmds.delete(cube[0])
	if cmds.objExists(objSet):
		failures += 1

	if failures > 0:
		print "testBasicObjectSetMain (Test #1): FAILED\n"
		failures = 0

	# Test #2
	#
	# - Create a sphere and a cube.
	# - Create a custom MPxObjectSet and add the sphere to the set.
	# - Connect the cube.message -> set.usedBy.
	# - Delete the sphere.
	# - Ensure the set is still present.
	#
	cmds.file(f=True, new=True)
	sphere = cmds.polySphere(r=1, sx=20, sy=20, ax=(0, 1, 0), tx=1, ch=1)
	cube = cmds.polyCube(w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 1, 0), tx=1, ch=1)
	cmds.select(sphere[0])
	objSet = maya.mel.eval("spBasicObjectSetTest")
	cmds.connectAttr("%s.message" % cube[0], "%s.usedBy[0]" % objSet)
	cmds.delete(sphere[0])
	if not cmds.objExists(objSet):
		failures += 1

	if failures > 0:
		print "testBasicObjectSetMain (Test #1): FAILED\n"

	# Clamp failures to 1.
	#
	if failures > 1:
		failures = 1

	return failures
Beispiel #19
0
def test_collection():
    """Collecting clean model works"""
    cmds.polyCube(name="ben_GEO")
    cmds.group(name="ben_GRP")

    with lib.registered("CollectModel"):
        context = pyblish.util.select()

    assert context["ben"]
Beispiel #20
0
	def setFromName(self, name):
		if cmds.objExists(name):
			self.position = V(cmds.getAttr("{0}.translate".format(name))[0])
			boundaryScale = cmds.getAttr("{0}.scale".format(name))[0]
			self.dimensions[0] = cmds.polyCube(name, query=True, width=True) * boundaryScale[0]
			self.dimensions[1] = cmds.polyCube(name, query=True, height=True) * boundaryScale[1]
			self.dimensions[2] = cmds.polyCube(name, query=True, depth=True) * boundaryScale[2]
		else:
			print "box with name \"{0}\" does not exist".format(name)
def RandomCube():
    cmds.polyCube( h = random.randrange(1,50), w = random.randrange(1,50), d = random.randrange(1,50), sx = 4, sy = 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))
def draw():
        for x in range(0,600):
                real = x / 200.0 - 1.5
                for y in range(0,600):
                        img = y / 200.0 - 1.5
                        c = complex(real, img)
                        if mandel(c):
                                print("point",str(real),str(img))
                                cmds.polyCube(h=1,w=1,d=1)
                                cmds.move(real*200,img*200,0)                     
Beispiel #23
0
 def test_bind_to_cmds_string(self):
     ex = self.Example('cube', 45)
     cmds.file(new=True, f=True)
     cmds.polyCube()
     tester = ex & 'val' > bindings.bind() > ('pCube1', 'tx')
     tester()
     assert cmds.getAttr('pCube1.tx') == 45
     tester2 = ex & 'val' > bindings.bind() > 'pCube1.ty'
     tester2()
     assert cmds.getAttr('pCube1.ty') == 45
Beispiel #24
0
def modify_lite_scene(filepath):
    #Use the maya.cmds module to manipulate Maya
    cmds.scriptEditorInfo(
        suppressInfo=True,
        suppressResults=True,
        suppressErrors=True,
        suppressWarnings=True)
    cmds.file(filepath, open=True, force=True)
    cmds.polyCube(name="my_cuber2")
    cmds.file(save=True, force=True)
    def testStaticTransformReadWrite(self):
        MayaCmds.polyCube(n='cube')
        MayaCmds.group(n='group1')
        MayaCmds.duplicate()

        self.failUnlessRaises(RuntimeError, MayaCmds.AbcExport,
            j='-root group1|cube -root group2|cube -f dupRoots.abc')

        # the abc file shouldn't exist
        self.failUnless(not os.path.isfile('dupRoots.abc'))
Beispiel #26
0
    def test_cubes_thin_plate(self):
        print "###################################################"
        print "TEST CUBES THIN PLATE KERNEL"
        cube_test = cmds.polyCube()[0]

        cube_a = cmds.polyCube()[0]
        cube_b = cmds.polyCube()[0]
        cube_c = cmds.polyCube()[0]

        cmds.setAttr(cube_a + ".translate", -1, 0, 0)
        cmds.setAttr(cube_b + ".translate", 0, 0, 1)
        cmds.setAttr(cube_c + ".translate", 1, 0, 0)

        cmds.setAttr(cube_a + ".scale", 2, 1, 1)
        cmds.setAttr(cube_b + ".scale", 1, 2, 1)
        cmds.setAttr(cube_c + ".scale", 1, 1, 2)
        success = self.create_rbfblender()
        cmds.setAttr("blender.rbfKernel", 4)
        cmds.setAttr("blender.blurParameter", 2.0)
        self.assert_(success, "Failed to create the node.")
        
        try:
            cmds.connectAttr(cube_test + ".translateX", "blender.input[0]")
            cmds.connectAttr(cube_test + ".translateZ", "blender.input[1]")
            
            cmds.connectAttr("blender.output[0]", cube_test + ".scaleX")
            cmds.connectAttr("blender.output[1]", cube_test + ".scaleY")
            cmds.connectAttr("blender.output[2]", cube_test + ".scaleZ")
            
            print "!! Creating pose 0"
            cmds.connectAttr(cube_a + ".translateX", "blender.poses[0].poseInputs[0]")
            cmds.connectAttr(cube_a + ".translateZ", "blender.poses[0].poseInputs[1]")
            cmds.connectAttr(cube_a + ".scaleX", "blender.poses[0].poseValues[0]")
            cmds.connectAttr(cube_a + ".scaleY", "blender.poses[0].poseValues[1]")
            cmds.connectAttr(cube_a + ".scaleZ", "blender.poses[0].poseValues[2]")
            
            print "!! Creating pose 1"
            cmds.connectAttr(cube_b + ".translateX", "blender.poses[1].poseInputs[0]")
            cmds.connectAttr(cube_b + ".translateZ", "blender.poses[1].poseInputs[1]")
            cmds.connectAttr(cube_b + ".scaleX", "blender.poses[1].poseValues[0]")
            cmds.connectAttr(cube_b + ".scaleY", "blender.poses[1].poseValues[1]")
            cmds.connectAttr(cube_b + ".scaleZ", "blender.poses[1].poseValues[2]")
            
            print "!! Creating pose 2"
            cmds.connectAttr(cube_c + ".translateX", "blender.poses[2].poseInputs[0]")
            cmds.connectAttr(cube_c + ".translateZ", "blender.poses[2].poseInputs[1]")
            cmds.connectAttr(cube_c + ".scaleX", "blender.poses[2].poseValues[0]")
            cmds.connectAttr(cube_c + ".scaleY", "blender.poses[2].poseValues[1]")
            cmds.connectAttr(cube_c + ".scaleZ", "blender.poses[2].poseValues[2]")
            
            success = True
        except Exception, e:
            success = False
            print e
Beispiel #27
0
 def buttonCreateOBBClicked(self):
     selection = cmds.ls(sl=True, tr=True)
     if len(selection) != 0:
         translate = cmds.xform(selection[0], q=True, t=True)
         
         cmds.polyCube( sx=1, sy=1, sz=1, h=1 )
         cmds.xform(t=translate)
         cmds.select(selection[0], add=True)
         cmds.parent()
     else:
         cmds.warning("Select an object in order to add a boundingbox.")
Beispiel #28
0
    def test_only_namespaces(self):
        try:
            cmds.file(new=True, force=True)
            p1 = cmds.polyCube()
            ns = cmds.namespace(add="test")
            cmds.namespace(set="test")
            p2 = cmds.polyCube()
            assert len(Meshes().execute()) == 2
            assert len(Meshes().only(namespace="test").execute()) == 1

        finally:
            cmds.file(new=True, force=True)
Beispiel #29
0
    def runTest(self):
        for cmdName in ('aimConstraint', 'orientConstraint'):
            cube1 = cmds.polyCube()[0]
            cube2 = cmds.polyCube()[0]

            cmd = getattr(cmds, cmdName)            
            constraint = cmd(cube1, cube2)[0]
            
            setVals = (12, 8, 7)
            cmd(constraint, e=1, offset=setVals)
            getVals = tuple(cmd(constraint, q=1, offset=1))
            self.assertVectorsEqual(setVals, getVals)
Beispiel #30
0
    def test_having(self):
        try:
            cmds.file(new=True, f=True)
            cmds.polyCube(name='no_attrib')
            cmds.polyCube(name='has_attrib')
            cmds.addAttr(ln='custom_attrib')
            with_attrib = Transforms().having('custom_attrib')
            assert '|has_attrib' in with_attrib
            assert '|no_attrib' not in with_attrib

        finally:
            cmds.file(new=True, force=True)
sessionId = 0
trackedCubeId = 0
currentBoxName = ''
singleFilter = "All Files (*.*)"
dialogResuls = cmds.fileDialog2(fileMode=1, caption="Select Log File")

if dialogResuls != None:
    filePath = dialogResuls[0]
    qbfile = open(filePath, 'r')

    for aline in qbfile.readlines():
        if aline.startswith('Begin Logger Session'):
            sessionId = sessionId + 1
            currentBoxName = 'cameraProxy' + str(sessionId)
            cmds.polyCube(name=currentBoxName)
        values = aline.split(',')
        if values[0] == 'Log Entry' and currentBoxName != '':
            frameValue = values[1]
            positionValues = values[2].split(' ')
            rotationValues = values[3].split(' ')
            cmds.setKeyframe(currentBoxName,
                             time=eval(frameValue),
                             attribute='translateX',
                             v=eval(positionValues[0]))
            cmds.setKeyframe(currentBoxName,
                             time=eval(frameValue),
                             attribute='translateY',
                             v=eval(positionValues[1]))
            cmds.setKeyframe(currentBoxName,
                             time=eval(frameValue),
Beispiel #32
0
cmds.closeCurve(ps=0, ch=0, rpo=1)

paintCurve('master_crv', c)

cmds.parent(master_crv, main_group)

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

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

root_geo = cmds.polyCube(name='root_center_geo', sy=2, sx=2)
cmds.scale(0.154, 0.154, 0.122)
cmds.move(0, 1.093, 0)
cmds.polyMoveFacet('root_center_geo.f[10]', 'root_center_geo.f[11]', ty=-0.07)
cmds.polyMoveEdge('root_center_geo.e[30]', 'root_center_geo.e[31]', sx=1.35)
cmds.polyMoveEdge('root_center_geo.e[27]', 'root_center_geo.e[29]', sx=1.45)
cmds.polyMoveEdge('root_center_geo.e[16]',
                  'root_center_geo.e[13]',
                  'root_center_geo.e[22]',
                  'root_center_geo.e[25]',
                  sz=1.25)

root = BodyPart('root', c, 'root_center_crv', 'root_center_geo')
root.defineFather(master)

# WAIST
Beispiel #33
0
def armoireUp():

    #group MODULE
    mir = random.randint(0, 19)
    crazyR = random.randint(0, 1000)
    mName = 'MODULE' + str(mir) + str(crazyR)
    uName = 'MEUBLE_UP' + str(mir) + str(crazyR)
    # planche_height = 5
    # planche_width = 0.1
    # planche_depth = 2
    # module_width = 4
    # number_modules = 3
    planche_height = cmds.intSliderGrp(slider1, q=True, value=True)
    planche_width = cmds.floatSliderGrp(slider2, q=True, value=True)
    planche_depth = cmds.intSliderGrp(slider3, q=True, value=True)
    module_width = cmds.intSliderGrp(slider4, q=True, value=True)
    number_modules = cmds.intSliderGrp(slider5, q=True, value=True)

    #group MODULE

    cmds.group(n=mName, em=True)
    cmds.group(n=uName, em=True)

    #laterales
    for i in range(0, 2):
        planche = cmds.polyCube(h=planche_height,
                                w=planche_width,
                                depth=planche_depth)
        cmds.polyBevel3(offset=0.02)
        cmds.move(-i * module_width + module_width / 2.0, planche_height / 2.0,
                  0)
        cmds.parent(planche, mName, relative=True)
    #superior - inferior
    for i in range(0, 3):
        placheUpDown = cmds.polyCube(h=planche_width,
                                     w=module_width,
                                     depth=planche_depth)
        cmds.polyBevel3(offset=0.02)
        cmds.move(0, i * planche_height / 2.0, 0)
        cmds.parent(placheUpDown, mName, relative=True)
    #puerta
    puerta = cmds.polyCube(h=planche_height + planche_width,
                           w=module_width + planche_width,
                           depth=planche_width * 2.0)
    cmds.polyBevel3(offset=0.03)
    cmds.move(0, planche_height / 2.0,
              planche_depth / 2.0 + planche_width / 2.0)
    cmds.parent(puerta, mName, relative=True)

    #respaldo
    respaldo = cmds.polyCube(h=planche_height + planche_width,
                             w=module_width + planche_width,
                             depth=planche_width)
    cmds.polyBevel3(offset=0.03)
    cmds.move(0, planche_height / 2.0,
              -planche_depth / 2.0 + planche_width / 2.0)
    cmds.parent(respaldo, mName, relative=True)

    for i in range(1, number_modules):
        mNameInstance = cmds.instance(mName)
        cmds.move(i * (module_width + planche_width), 0, 0, mNameInstance)
        cmds.parent(mNameInstance, uName, relative=True)

    cmds.parent(mName, uName, relative=True)
Beispiel #34
0
def MakeSleeper():
    detailGeo = []

    cube01 = mc.polyCube(w=0.6, h=.1, d=.6)
    mc.move(0, 0.2, 3.5)
    detailGeo.append(cube01[0])

    cube02 = mc.polyCube(w=0.6, h=.1, d=.6)
    mc.move(0, 0.2, 3.5)
    detailGeo.append(cube02[0])

    cube03 = mc.polyCube(w=0.6, h=.26, d=.137)
    mc.move(0, 0.24, 3.34)
    detailGeo.append(cube03[0])

    cylinder01 = mc.polyCylinder()
    mc.scale(0.13, 0.13, 0.13)
    mc.move(0.15, 0.16, 3.6)
    detailGeo.append(cylinder01[0])

    cylinder02 = mc.polyCylinder()
    mc.scale(0.13, 0.13, 0.13)
    mc.move(-0.15, 0.16, 3.6)
    detailGeo.append(cylinder02[0])

    cylinder03 = mc.polyCylinder()
    mc.scale(0.09, 0.13, 0.09)
    mc.move(0.15, 0.3, 3.6)
    detailGeo.append(cylinder03[0])

    cylinder04 = mc.polyCylinder()
    mc.scale(0.09, 0.13, 0.09)
    mc.move(-0.15, 0.3, 3.6)
    detailGeo.append(cylinder04[0])

    cylinder05 = mc.polyCylinder()
    mc.rotate(0, 0, 90)
    mc.scale(0.09, 0.324, 0.09)
    mc.move(0, 0.363, 3.345)
    detailGeo.append(cylinder05[0])

    # Duplicating the detail geometry
    detail = mc.group(detailGeo)
    detailDuplicate = mc.duplicate(rr=True)
    mc.scale(1, 1, -1, r=True)
    mc.move(0, 0, -7, r=True)

    # Sleeper Board
    board = mc.polyCube(w=1, h=.3, d=10)

    # Grouping single sleeper
    sleeper = []
    sleeper.append(
        detail)  # to add the string 'group1' to a list you have to use append
    sleeper.extend(
        detailDuplicate
    )  # you have to extend the duplicate to pull it out the string it is formed in
    sleeper.append(board[0])
    singleSleeper = mc.group(sleeper, n="Sleeper1")
    mc.rotate(0, 90, 0)

    return singleSleeper
Beispiel #35
0
def make_proxy(nodes):
    for node in nodes:
        # print node
        proxy = mc.polyCube(n=(node + '_proxy'))[0]
        extract_edits(node, proxy)
Beispiel #36
0
    def testset_useapi(self):
        cmds.file(new=True, f=True)
        cube = cmds.polyCube()[0]
        print cube
        m = mtn.M(u"pCube1")
        m.tx.set(1)
        assert (m.tx.get() == 1)
        m.tx.set_useapi(2)
        assert (m.tx.get() == 2)
        m.t.set(1, 1, 1)
        assert (m.t.get() == [1, 1, 1])
        m.t.set_useapi(1, 1, 1)
        assert (m.t.get() == [1, 1, 1])
        m.t.set([1, 2, 3])
        assert (m.t.get() == [1, 2, 3])
        m.t.set_useapi([1, 2, 3])
        assert (m.t.get() == [1, 2, 3])
        m.t.set(Vector(3, 1, 2))
        assert (m.t.get() == [3, 1, 2])
        m.t.set_useapi(Vector(3, 1, 2))
        assert (m.t.get() == [3, 1, 2])

        m.rx.set(0.349)
        self.failUnlessAlmostEqual(m.rx.get(), 0.349)
        m.rx.set(0)
        assert (m.rx.get() == 0)
        m.rx.set_useapi(0.349)
        self.failUnlessAlmostEqual(m.rx.get(), 0.349)
        m.rx.set_useapi(0)
        assert (m.rx.get() == 0)
        m.r.set(.3, .4, .5)
        self.failUnlessAlmostEqual(m.rx.get(), 0.3)
        self.failUnlessAlmostEqual(m.ry.get(), 0.4)
        self.failUnlessAlmostEqual(m.rz.get(), 0.5)
        m.r.set_useapi(.1, .2, .3)
        self.failUnlessAlmostEqual(m.rx.get(), 0.1)
        self.failUnlessAlmostEqual(m.ry.get(), 0.2)
        self.failUnlessAlmostEqual(m.rz.get(), 0.3)

        m.sx.set(2)
        assert (m.sx.get() == 2)
        m.sx.set_useapi(1)
        assert (m.sx.get() == 1)
        m.s.set(1, 1, 1)
        assert (m.s.get() == [1, 1, 1])
        m.s.set_useapi(1, 1, 1)
        assert (m.s.get() == [1, 1, 1])
        m.s.set([1, 2, 3])
        assert (m.s.get() == [1, 2, 3])
        m.s.set_useapi([1, 2, 3])
        assert (m.s.get() == [1, 2, 3])
        m.s.set(Vector(3, 1, 2))
        assert (m.s.get() == [3, 1, 2])
        m.s.set_useapi(Vector(3, 1, 2))
        assert (m.s.get() == [3, 1, 2])

        m = mtn.M("pCubeShape1")
        # bool
        m.colorSet[0].clamped.set(False)
        assert (m.colorSet[0].clamped.get() == False)
        m.colorSet[0].clamped.set_useapi(False)
        assert (m.colorSet[0].clamped.get() == False)
        m.colorSet[0].clamped.set(1)
        assert (m.colorSet[0].clamped.get() == True)
        m.colorSet[0].clamped.set_useapi(1)
        assert (m.colorSet[0].clamped.get() == True)
        # enum
        m.colorSet[0].representation.set(2)
        assert (m.colorSet[0].representation.get() == 2)
        m.colorSet[0].representation.set_useapi(2)
        assert (m.colorSet[0].representation.get() == 2)
        m.colorSet[0].representation.set(4)
        assert (m.colorSet[0].representation.get() == 4)
        m.colorSet[0].representation.set_useapi(4)
        assert (m.colorSet[0].representation.get() == 4)
        # string
        m.currentColorSet.set(u"hokuhoku")
        assert (m.currentColorSet.get() == u"hokuhoku")
        m.currentColorSet.set(u"")
        assert (m.currentColorSet.get() == u"")
        m.currentColorSet.set_useapi(u"hokuhoku")
        assert (m.currentColorSet.get() == u"hokuhoku")
        m.currentColorSet.set_useapi(u"")
        assert (m.currentColorSet.get() == u"")
        # int
        m = mtn.M("polyCube1")
        m.subdivisionsWidth.set(2)
        assert (m.subdivisionsWidth.get() == 2)
        m.subdivisionsWidth.set_useapi(2)
        assert (m.subdivisionsWidth.get() == 2)
        m.subdivisionsWidth.set(1)
        assert (m.subdivisionsWidth.get() == 1)
        m.subdivisionsWidth.set_useapi(1)
        assert (m.subdivisionsWidth.get() == 1)

        cmds.circle()
        m = mtn.M(u"nurbsCircleShape1")
        assert (m.mmv.get() == [0.0, 8.0])
        assert (m.minMaxValue.get() == [0.0, 8.0])

        # simple compound attribute
        cmds.createNode("quatAdd")
        m = mtn.M("quatAdd1")
        m.input1Quat.set(1, 1, 1, 1)
        assert (m.input1Quat.get() == [1.0, 1.0, 1.0, 1.0])
        m.input1Quat.set(2, 3, 4, 5)
        assert (m.input1Quat.get() == [2.0, 3.0, 4.0, 5.0])
        m.input1Quat.set_useapi(1, 1, 1, 1)
        assert (m.input1Quat.get() == [1.0, 1.0, 1.0, 1.0])
        m.input1Quat.set_useapi(2, 3, 4, 5)
        assert (m.input1Quat.get() == [2.0, 3.0, 4.0, 5.0])

        # matrix
        cmds.createNode(u"addMatrix")
        m = mtn.M(u"addMatrix1")
        # cmds
        m.i[0].set(5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1)
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1)))')
        m.i[0].set([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((0, 0, 0, 0), (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3)))')
        m.i[0].set(mtn.Matrix())
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)))')
        # m.i[0].set([[0,0,0,0],[1,1,1,1],[2,2,2,2],[3,3,3,3]])
        # assert(repr(m.matrixSum.get()) == 'Matrix(((0, 0, 0, 0), (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3)))')
        # m.i[0].set([5,1,1,1],[5,1,1,1],[5,1,1,1],[5,1,1,1])
        # assert(repr(m.matrixSum.get()) == 'Matrix(((5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1)))')

        # api
        m.i[0].set_useapi(5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1)
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1)))')
        m.i[0].set_useapi([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((0, 0, 0, 0), (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3)))')
        m.i[0].set_useapi(mtn.Matrix())
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)))')
        m.i[0].set_useapi([[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2],
                           [3, 3, 3, 3]])
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((0, 0, 0, 0), (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3)))')
        m.i[0].set_useapi([5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1],
                          [5, 1, 1, 1])
        assert (
            repr(m.matrixSum.get()) ==
            'Matrix(((5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1), (5, 1, 1, 1)))')
Beispiel #37
0
def polyCube():
    cmds.polyCube()
Beispiel #38
0
 def make_cube(cls):
     cmds.polyCube()
 def point_cube():
     cube = cmds.polyCube(createUVs=0, constructionHistory=False)
     cmds.scale(0, 0, 0, cube)
     return cube[0]
Beispiel #40
0
import maya.cmds as cmds

# Cleanup
if cmds.ls('ground'):
    cmds.delete('ground')

particleList = cmds.ls('myParticle*')

if len(particleList) > 0:
    cmds.delete(particleList)

# Create the ground plane
cmds.polyCube(sx=10, sy=15, sz=5, w=5, d=5, h=0.01, name='ground')

noParticles = 0

# Create particles
for i in range(2):
    for j in range(2):
        particle = cmds.polySphere(n='myParticle#', sx=6, sy=6, r=0.05)
        cmds.move(i * 0.1, 3, j * 0.1, particle)
        noParticles += 1

#particleList = cmds.ls('myParticle*')
print str(noParticles) + " particles created"
# Cube Handler Maya Program

import maya.cmds as cmds

cube = cmds.polyCube()
cubeShape = cube[0]

circle = cmds.circle()
circleShape = circle[0]

cmds.parent(cubeShape, circleShape)

cmds.setAttr("pCube1.translate", lock=True)
cmds.setAttr("pCube1.rotate", lock=True)
cmds.setAttr("pCube1.scale", lock=True)
import maya.cmds as cmds

result = cmds.polyCube( ch=True, o=True, w=9.265, h=9.423 , name=FirstCube#)

print "result: " + str(result)
Beispiel #43
0
def create_geo(size=4):
    cmds.polyCube(w=size, h=size, d=size)
    cmds.move(0, 0, -10)
    cmds.polyCylinder(r=size)
    cmds.polySphere(r=size)
    cmds.move(0, 0, 10)
Beispiel #44
0
############################################
#예제 1 - 100개의 임의의 높이를 갖는 cube 만들기
############################################

import maya.cmds as cmds
import random
#box 100개를 생산하기

for x in range(100):
    //random.uniform(a,b): a<=n<=b의 실수값 n을 반환
    rand_height=random.uniform(0,10)
    //polyCube() 함수는 polygonal cube를 생산하는 함수
    //polyCube() 함수는 객체 이름과 node 이름으로 구성된 
    cube=cmds.polyCube(height=rand_height) 
    //cube 리스트로 저장이 된다
    //print(cube)
    //move(x,y,z,object,...) 함수는 객체를 좌표에 따라서 이동
    //cube의 높이를 반씩 이동하여 높이를 바닥에 맞춤
    cmds.move(x,rand_height/2,0,cube[0])
Beispiel #45
0
 def createPolyCube(self, meshContainer, cubeWidth, voxelCenterPosition):
     mDagNode = OpenMaya.MFnDagNode()
     myCube = cmds.polyCube(w=cubeWidth, h=cubeWidth, d=cubeWidth)
     cmds.move(voxelCenterPosition.x, voxelCenterPosition.y,
               voxelCenterPosition.z, myCube)
     cmds.parent(myCube[0], meshContainer)
Beispiel #46
0
def MakeCars():
    trainCarTop = []

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

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

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

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

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

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

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

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

    theFrikinMain = mc.group(trainCarTop)

    # Wheels on the cars

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

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

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

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

    wheelsRight = mc.group(carWheels)

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

    # Group all geometry in car

    theCar = []
    theCar.append(theFrikinMain)
    theCar.append(wheelsRight)
    theCar.extend(wheelsLeft)
    groupedCar = mc.group(theCar, n="Car1")

    carList = []
    carList.append(groupedCar)

    # Number of Cars

    for i in range(1, numCars):
        curCar = mc.duplicate(rr=True, ic=True)
        mc.move(-42.81, 0, 0, r=True)
        carList.append(curCar[0])

    return carList
Beispiel #47
0
def makeCube():
    cmds.polyCube()
    print("Make a cube!")
Beispiel #48
0
def MakeTrack():
    # Detail geometry on the sleepers
    detailGeo = []

    cube01 = mc.polyCube(w=0.6, h=.1, d=.6)
    mc.move(0, 0.2, 3.5)
    detailGeo.append(cube01[0])

    cube02 = mc.polyCube(w=0.6, h=.1, d=.6)
    mc.move(0, 0.2, 3.5)
    detailGeo.append(cube02[0])

    cube03 = mc.polyCube(w=0.6, h=.26, d=.137)
    mc.move(0, 0.24, 3.34)
    detailGeo.append(cube03[0])

    cylinder01 = mc.polyCylinder()
    mc.scale(0.13, 0.13, 0.13)
    mc.move(0.15, 0.16, 3.6)
    detailGeo.append(cylinder01[0])

    cylinder02 = mc.polyCylinder()
    mc.scale(0.13, 0.13, 0.13)
    mc.move(-0.15, 0.16, 3.6)
    detailGeo.append(cylinder02[0])

    cylinder03 = mc.polyCylinder()
    mc.scale(0.09, 0.13, 0.09)
    mc.move(0.15, 0.3, 3.6)
    detailGeo.append(cylinder03[0])

    cylinder04 = mc.polyCylinder()
    mc.scale(0.09, 0.13, 0.09)
    mc.move(-0.15, 0.3, 3.6)
    detailGeo.append(cylinder04[0])

    cylinder05 = mc.polyCylinder()
    mc.rotate(0, 0, 90)
    mc.scale(0.09, 0.324, 0.09)
    mc.move(0, 0.363, 3.345)
    detailGeo.append(cylinder05[0])

    # Duplicating the detail geometry
    detail = mc.group(detailGeo)
    detailDuplicate = mc.duplicate(rr=True)
    mc.scale(1, 1, -1, r=True)
    mc.move(0, 0, -7, r=True)

    # Sleeper Board
    board = mc.polyCube(w=1, h=.3, d=10)

    # Grouping single sleeper
    sleeper = []
    sleeper.append(
        detail)  # to add the string 'group1' to a list you have to use append
    sleeper.extend(
        detailDuplicate
    )  # you have to extend the duplicate to pull it out the string it is formed in
    sleeper.append(board[0])
    singleSleeper = mc.group(sleeper)

    # Making Sleepers
    sleepers = []
    sleepers.append(singleSleeper)

    negSleeperNum = 20 + (numCars * 17)

    if numSleepers > negSleeperNum:
        for i in range(1, negSleeperNum):
            curSleeper = mc.duplicate(rr=True)
            mc.move(-distSleepers * i, 0, 0)
            sleeperCurve = random.randrange(-rotAmp, rotAmp)
            mc.rotate(0, sleeperCurve, 0)
            sleepers.extend(curSleeper)

        rail1 = mc.polyCube(w=negSleeperNum * distSleepers, h=1, d=0.4)
        mc.move(-((negSleeperNum - 1) * distSleepers) / 2, 0.6, 3)
        sleepers.append(rail1[0])

        rail2 = mc.duplicate(rr=True)
        mc.move(0, 0, -6, r=True)
        sleepers.append(rail2[0])

        rail3 = mc.polyCube(w=negSleeperNum * distSleepers, h=0.2, d=0.59)
        mc.move(-((negSleeperNum - 1) * distSleepers) / 2, 1.1, 3.1)
        sleepers.append(rail3[0])

        rail4 = mc.duplicate(rr=True)
        mc.move(0, 0, -6.2, r=True)
        sleepers.append(rail4[0])

        posSleeperNum = numSleepers - negSleeperNum
        mc.select(singleSleeper)

        for i in range(1, posSleeperNum):
            curSleeper = mc.duplicate(rr=True)
            mc.move(distSleepers * i, 0, 0)
            sleeperCurve = random.randrange(-rotAmp, rotAmp)
            mc.rotate(0, sleeperCurve, 0)
            sleepers.extend(curSleeper)

        rail5 = mc.polyCube(w=posSleeperNum * distSleepers, h=1, d=0.4)
        mc.move(((posSleeperNum - 1) * distSleepers) / 2, 0.6, 3)
        sleepers.append(rail5[0])

        rail6 = mc.duplicate(rr=True)
        mc.move(0, 0, -6, r=True)
        sleepers.append(rail6[0])

        rail7 = mc.polyCube(w=posSleeperNum * distSleepers, h=0.2, d=0.59)
        mc.move(((posSleeperNum - 1) * distSleepers) / 2, 1.1, 3.1)
        sleepers.append(rail7[0])

        rail8 = mc.duplicate(rr=True)
        mc.move(0, 0, -6.2, r=True)
        sleepers.append(rail8[0])

    else:
        for i in range(1, numSleepers):
            curSleeper = mc.duplicate(rr=True)
            mc.move(-distSleepers * i, 0, 0)
            sleeperCurve = random.randrange(-rotAmp, rotAmp)
            mc.rotate(0, sleeperCurve, 0)
            sleepers.extend(curSleeper)

        rail1 = mc.polyCube(w=numSleepers * distSleepers, h=1, d=0.4)
        mc.move(-((numSleepers - 1) * distSleepers) / 2, 0.6, 3)
        sleepers.append(rail1[0])

        rail2 = mc.duplicate(rr=True)
        mc.move(0, 0, -6, r=True)
        sleepers.append(rail2[0])

        rail3 = mc.polyCube(w=numSleepers * distSleepers, h=0.2, d=0.59)
        mc.move(-((numSleepers - 1) * distSleepers) / 2, 1.1, 3.1)
        sleepers.append(rail3[0])

        rail4 = mc.duplicate(rr=True)
        mc.move(0, 0, -6.2, r=True)
        sleepers.append(rail4[0])

    # Group the whole rail
    finalRail = mc.group(sleepers, n="Rail")

    return finalRail
Beispiel #49
0
def createCube(size, name):
    cmds.polyCube(h=size, w=size, d=size, name=name)
Beispiel #50
0
    def test_get(self):
        cmds.file(new=True, f=True)
        cube = cmds.polyCube()[0]
        print cube
        m = mtn.M(u"pCube1")

        print 'm.t.get()', m.t.get()
        print 'm.translate.get()', m.translate.get()
        print 'm.tx.get()', m.tx.get()
        print 'm.translateX.get()', m.translateX.get()
        print 'm.t.x.get()', m.t.x.get()
        print 'm.translate.x.get()', m.translate.x.get()
        print 'm.t.tx.get()', m.t.tx.get()
        print 'm.translate.translateX.get()', m.translate.translateX.get()
        print " "
        print 'm.attr("t").get()', m.attr("t").get()
        print 'm.attr("translate").get()', m.attr("translate").get()
        print 'm.attr("tx").get()', m.attr("tx").get()
        print 'm.attr("translateX").get()', m.attr("translateX").get()
        print 'm.attr("t").x.get()', m.attr("t").x.get()
        print 'm.attr("translate").x.get()', m.attr("translate").x.get()
        print 'm.attr("t").tx.get()', m.attr("t").tx.get()
        print 'm.attr("translate").tx.get()', m.attr("translate").tx.get()
        print 'm.attr("t").attr("x").get()', m.attr("t").attr("x").get()
        print 'm.attr("translate").attr("x").get()', m.attr("translate").attr(
            "x").get()
        print 'm.attr("t").attr("tx").get()', m.attr("t").attr("tx").get()
        print 'm.attr("translate").attr("translateX").get()', m.attr(
            "translate").attr("translateX").get()
        print " "
        print 'm.m.get()', m.m.get()
        print 'm.matrix.get()', m.matrix.get()
        print 'm.pim.get()', m.pim.get()
        print 'm.parentInverseMatrix.get()', m.parentInverseMatrix.get()
        print 'm.pim[0].get()', m.pim[0].get()
        print 'm.parentInverseMatrix[0].get()', m.parentInverseMatrix[0].get()
        print 'm.attr("pim").get()', m.attr("pim").get()
        print 'm.attr("parentInverseMatrix").get()', m.attr(
            "parentInverseMatrix").get()
        print 'm.attr("pim")[0].get()', m.attr("pim")[0].get()
        print 'm.attr("parentInverseMatrix")[0].get()', m.attr(
            "parentInverseMatrix")[0].get()
        print 'm.attr("pim[0]").get()', m.attr("pim[0]").get()
        print 'm.attr("parentInverseMatrix[0]").get()', m.attr(
            "parentInverseMatrix[0]").get()

        assert (
            repr(m.t.getChildren()) ==
            u'[Attribute("pCube1.translateX"), Attribute("pCube1.translateY"), Attribute("pCube1.translateZ")]'
        )

        print "=" * 20

        cmds.circle()
        m = mtn.M(u"nurbsCircleShape1")
        assert (m.wn.get() == [[0.0, 0.0, 1.0]])
        assert (m.attr("wn").get() == [[0.0, 0.0, 1.0]])
        assert (m.worldNormal.get() == [[0.0, 0.0, 1.0]])
        assert (m.attr("worldNormal").get() == [[0.0, 0.0, 1.0]])
        assert (m.wn[0].get() == [0.0, 0.0, 1.0])
        assert (m.attr("wn")[0].get() == [0.0, 0.0, 1.0])
        assert (m.attr("wn[0]").get() == [0.0, 0.0, 1.0])
        assert (m.worldNormal[0].get() == [0.0, 0.0, 1.0])
        assert (m.attr("worldNormal")[0].get() == [0.0, 0.0, 1.0])
        assert (m.attr("worldNormal[0]").get() == [0.0, 0.0, 1.0])
        assert (m.wn.wnx.get() == 0.0)
        assert (m.attr("wn").wnx.get() == 0.0)
        assert (m.attr("wn").attr("wnx").get() == 0.0)
        assert (m.worldNormal.wnx.get() == 0.0)
        assert (m.attr("worldNormal").wnx.get() == 0.0)
        assert (m.attr("worldNormal").attr("wnx").get() == 0.0)
        assert (m.worldNormal.worldNormalX.get() == 0.0)
        assert (m.attr("worldNormal").worldNormalX.get() == 0.0)
        assert (m.attr("worldNormal").attr("worldNormalX").get() == 0.0)
        assert (m.wn.x.get() == 0.0)
        assert (m.attr("wn").x.get() == 0.0)
        assert (m.attr("wn").attr("x").get() == 0.0)
        assert (m.worldNormal.x.get() == 0.0)
        assert (m.attr("worldNormal").x.get() == 0.0)
        assert (m.attr("worldNormal").attr("x").get() == 0.0)
        assert (m.worldNormal[0].wnx.get() == 0.0)
        assert (m.attr("worldNormal")[0].wnx.get() == 0.0)
        assert (m.attr("worldNormal")[0].attr("wnx").get() == 0.0)
        assert (m.attr("worldNormal[0]").wnx.get() == 0.0)
        assert (m.attr("worldNormal[0]").attr("wnx").get() == 0.0)
        assert (m.worldNormal[0].x.get() == 0.0)
        assert (m.attr("worldNormal")[0].x.get() == 0.0)
        assert (m.attr("worldNormal")[0].attr("x").get() == 0.0)
        assert (m.attr("worldNormal[0]").x.get() == 0.0)
        assert (m.attr("worldNormal[0]").attr("x").get() == 0.0)
        assert (m.worldNormal[0].worldNormalX.get() == 0.0)
        assert (m.attr("worldNormal")[0].worldNormalX.get() == 0.0)
        assert (m.attr("worldNormal")[0].attr("worldNormalX").get() == 0.0)
        assert (m.attr("worldNormal[0]").worldNormalX.get() == 0.0)
        assert (m.attr("worldNormal[0]").attr("worldNormalX").get() == 0.0)
        assert (m.mmv.get() == [0.0, 8.0])
        assert (m.minMaxValue.get() == [0.0, 8.0])
        assert (m.obcc.get() == [0.0, 0.0, 0.0])
        assert (m.attr("obcc").get() == [0.0, 0.0, 0.0])
        assert (m.objectColorRGB.get() == [0.0, 0.0, 0.0])
        assert (m.attr("objectColorRGB").get() == [0.0, 0.0, 0.0])
        assert (m.obcc.obcr.get() == 0.0)
        assert (m.attr("obcc").obcr.get() == 0.0)
        assert (m.attr("obcc").attr("obcr").get() == 0.0)
        assert (m.objectColorRGB.obcr.get() == 0.0)
        assert (m.attr("objectColorRGB").obcr.get() == 0.0)
        assert (m.attr("objectColorRGB").attr("obcr").get() == 0.0)
        assert (m.objectColorRGB.objectColorR.get() == 0.0)
        assert (m.attr("objectColorRGB").attr("objectColorR").get() == 0.0)
        assert (m.objectColorR.get() == 0.0)
        assert (m.attr("objectColorR").get() == 0.0)

        m = mtn.M(u"pCubeShape1")
        assert (m.vertexColor[0].vertexFaceColor[0].get() == [[0.0, 0.0, 0.0],
                                                              1.0])
        assert (m.attr("vertexColor")[0].vertexFaceColor[0].get() == [[
            0.0, 0.0, 0.0
        ], 1.0])
        assert (m.attr("vertexColor")[0].attr("vertexFaceColor")[0].get() == [[
            0.0, 0.0, 0.0
        ], 1.0])
        assert (m.attr("vertexColor[0]").attr("vertexFaceColor")[0].get() == [[
            0.0, 0.0, 0.0
        ], 1.0])
        assert (m.attr("vertexColor[0]").attr("vertexFaceColor[0]").get() == [[
            0.0, 0.0, 0.0
        ], 1.0])
        assert (
            m.vertexColor[0].vertexFaceColor[0].vertexFaceColorRGB.get() == [
                0.0, 0.0, 0.0
            ])
        assert (m.vertexColor[0].vertexFaceColor[0].attr(
            "vertexFaceColorRGB").get() == [0.0, 0.0, 0.0])
        assert (m.vertexColor[0].attr("vertexFaceColor")
                [0].vertexFaceColorRGB.get() == [0.0, 0.0, 0.0])
        assert (m.attr("vertexColor")
                [0].vertexFaceColor[0].vertexFaceColorRGB.get() == [
                    0.0, 0.0, 0.0
                ])
        assert (m.attr("vertexColor")[0].attr("vertexFaceColor")
                [0].vertexFaceColorRGB.get() == [0.0, 0.0, 0.0])
        assert (m.attr("vertexColor")[0].attr("vertexFaceColor")[0].attr(
            "vertexFaceColorRGB").get() == [0.0, 0.0, 0.0])
        assert (m.attr("vertexColor[0]").attr("vertexFaceColor")[0].attr(
            "vertexFaceColorRGB").get() == [0.0, 0.0, 0.0])
        assert (m.attr("vertexColor[0]").attr("vertexFaceColor[0]").attr(
            "vertexFaceColorRGB").get() == [0.0, 0.0, 0.0])

        assert (m.vertexColor[0].vertexFaceColor[0].vertexFaceColorRGB.
                vertexFaceColorB.get() == 0.0)

        mel.eval(
            "curve -d 3 -p -6.875966 0 1.086021 -p -5.392687 0 2.925972 -p -2.426129 0 6.605875 \
         -p 5.887674 0 7.227014 -p 2.9318 0 2.277118 -p -8.971029 0 -5.450958 -p 1.340971 0 4.394752 \
         -p -1.974355 0 6.056083 -p -3.632019 0 6.886748 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6 ;"
        )
        m = mtn.M(u"curveShape1")
        assert (m.cp.name() == u"curveShape1.controlPoints")
        assert (m.attr("cp").name() == u"curveShape1.controlPoints")
        assert (m.attr("controlPoints").name() == u"curveShape1.controlPoints")
        assert (m.cp.size() == 9)
        assert (m.attr("cp").size() == 9)
        assert (m.attr("controlPoints").size() == 9)
        assert (len(m.cp) == 9)
        assert (len(m.attr("cp")) == 9)
        assert (len(m.attr("controlPoints")) == 9)
        for a in m.controlPoints:
            print a.name(), a.get()

        assert (mtn.M(u"pCube1.t").name() == u'pCube1.translate')
        assert (mtn.M(u"pCube1.translate").name() == u'pCube1.translate')
        assert (mtn.M(u"pCube1.t.tx").name() == u'pCube1.translateX')
        assert (mtn.M(u"pCube1.translate.translateX").name() ==
                u'pCube1.translateX')
        assert (mtn.M(u"pCube1.tx").name() == u'pCube1.translateX')
        assert (mtn.M(u"pCube1.translateX").name() == u'pCube1.translateX')
        assert (mtn.M(u"pCube1.wm").name() == u'pCube1.worldMatrix')
        assert (mtn.M(u"pCube1.wm[0]").name() == u'pCube1.worldMatrix[0]')

        assert (mtn.M(
            u"pCubeShape1.vertexColor.vertexFaceColor.vertexFaceColorRGB.vertexFaceColorB"
        ).name(
        ) == u'pCubeShape1.vertexColor[0].vertexFaceColor[0].vertexFaceColorB')

        assert (mtn.M(
            u"pCubeShape1.vertexColor[0].vertexFaceColor[0].vertexFaceColorRGB.vertexFaceColorB"
        ).name(
        ) == u'pCubeShape1.vertexColor[0].vertexFaceColor[0].vertexFaceColorB')
Beispiel #51
0
def main():
    obj = cmds.polyCube()[0]
    ui = Example_connectAttr(node=obj)
    ui.show(dockable=True, floating=True)
    return ui
    def testBlendShapesExport(self):
        # NOTE: (yliangsiew) Basic blendshape export test.
        om.MFileIO.newFile(True)
        parent = cmds.group(name="root", empty=True)
        base, _ = cmds.polyCube(name="base")
        cmds.parent(base, parent)
        target, _ = cmds.polyCube(name="blend")
        cmds.parent(target, parent)
        cmds.polyMoveVertex('{}.vtx[0:2]'.format(target), s=(1.0, 1.5, 1.0))

        cmds.blendShape(target, base, automatic=True)

        cmds.select(base, replace=True)
        temp_file = os.path.join(self.temp_dir, 'blendshape.usda')
        cmds.mayaUSDExport(f=temp_file, v=True, sl=True, ebs=True, skl="auto")

        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/root/base/blendShape")
        offsets = prim.GetAttribute("offsets").Get()

        for i, coords in enumerate(offsets):
            coords = list(coords)  # convert from GfVec3
            self.assertEqual(coords, [0, -0.25 if i < 2 else 0.25, 0])
        """
        Sample BlendShape prim:

        def BlendShape "blendShape"
        {
            uniform vector3f[] normalOffsets = [(0, 0, 0), (0, 0, 0), (0, 0, 0)]
            uniform vector3f[] offsets = [(0, -0.25, 0), (0, -0.25, 0), (0, 0.25, 0)]
            uniform int[] pointIndices = [0, 1, 2]
        }
        """

        # NOTE: (yliangsiew) Test simple inbetween setup.
        om.MFileIO.open(self.scene_path, None, True)
        cmds.select("basic_cube_2_inbetweens_no_anim|base", r=True)
        cmds.mayaUSDExport(f=temp_file,
                           v=True,
                           sl=True,
                           ebs=True,
                           skl="auto",
                           skn="auto")
        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath(
            "/basic_cube_2_inbetweens_no_anim/base/pCube2")
        blendShape = UsdSkel.BlendShape(prim)
        inbetweens = blendShape.GetInbetweens()
        self.assertEqual(
            len(inbetweens), 2
        )  # NOTE: (yliangsiew) This particular setup has two additional inbetweens.

        # NOTE: (yliangsiew) Test simple multiple targets setup.
        om.MFileIO.open(self.scene_path, None, True)
        cmds.select("basic_cube_4_blendshapes_no_anim|base", r=True)
        cmds.mayaUSDExport(f=temp_file,
                           v=True,
                           sl=True,
                           ebs=True,
                           skl="auto",
                           skn="auto")
        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/basic_cube_4_blendshapes_no_anim/base")
        blendShapes = prim.GetChildren()
        for bs in blendShapes:
            self.assertEqual(bs.GetTypeName(), 'BlendShape')

        # NOTE: (yliangsiew) Test exporting empty blendshape targets.
        om.MFileIO.open(self.scene_path, None, True)
        cmds.select("cube_empty_blendshape_targets|base", r=True)
        cmds.mayaUSDExport(f=temp_file,
                           v=True,
                           sl=True,
                           ebs=True,
                           skl="auto",
                           skn="auto",
                           ignoreWarnings=True)
        stage = Usd.Stage.Open(temp_file)
        prim = stage.GetPrimAtPath("/cube_empty_blendshape_targets/base")
        blendShapes = prim.GetChildren()
        for bs in blendShapes:
            self.assertEqual(bs.GetTypeName(), 'BlendShape')
            skelBS = UsdSkel.BlendShape(bs)
            normalsAttr = skelBS.GetNormalOffsetsAttr()
            offsetsAttr = skelBS.GetOffsetsAttr()
            normals = normalsAttr.Get()
            offsets = offsetsAttr.Get()
            self.assertEqual(len(normals), 0)
            self.assertEqual(len(offsets), 0)
Beispiel #53
0
def runBed():

    # matela_Widthx = 12
    # matela_widthz = 8
    # matela_Height = 2
    # lit_extrude_y = 0.8
    # lit_extrude_Z = 0.85
    matela_Widthx = cmds.intSliderGrp(slider1, q=True, value=True)
    matela_widthz = cmds.intSliderGrp(slider2, q=True, value=True)
    matela_Height = cmds.intSliderGrp(slider3, q=True, value=True)
    lit_extrude_y = cmds.floatSliderGrp(slider4, q=True, value=True)
    lit_extrude_Z = cmds.floatSliderGrp(slider5, q=True, value=True)
    mir = random.randint(0, 19)
    crazyR = random.randint(0, 1000)
    gName = 'lit_complete' + str(mir) + str(crazyR)
    cmds.group(n=gName, em=True)

    #matelas
    matela = cmds.polyCube(h=matela_Height,
                           w=matela_Widthx,
                           depth=matela_widthz)
    cmds.polyBevel3(matela, offset=0.1)
    cmds.polySmooth(matela, divisions=3)
    cmds.parent(matela, gName, relative=True)

    #laterales
    lateralUno = cmds.polyCube(h=matela_Height, w=matela_Widthx, depth=0.4)
    cmds.move(0, -matela_Height / 2.0, -matela_widthz / 2.0)
    lateralInstance = cmds.instance(lateralUno)
    cmds.move(0, -matela_Height / 2.0, matela_widthz / 2.0)
    cmds.polyBevel3(offset=0.05)
    cmds.parent(lateralUno, gName, relative=True)
    cmds.parent(lateralInstance, gName, relative=True)

    #tete
    tete = cmds.polyCube(h=matela_Height * 2.0, w=0.5, depth=matela_widthz)
    cmds.move(-matela_Widthx / 2.0, 0, 0)
    rtete = cmds.ls(tete)
    cmds.polyExtrudeFacet(str(rtete[0]) + '.f[4]',
                          kft=False,
                          ls=(lit_extrude_Z, lit_extrude_y, 0))
    cmds.polyExtrudeFacet(str(rtete[0]) + '.f[4]', kft=False, ltz=-0.2)
    cmds.polyBevel3(offset=0.05)
    cmds.parent(tete, gName, relative=True)

    #pieds
    pied = cmds.polyCube(h=matela_Height, w=0.4, depth=matela_widthz)
    cmds.move(matela_Widthx / 2.0, -matela_Height / 2.0, 0)
    rpied = cmds.ls(pied)
    cmds.polyExtrudeFacet(str(rpied[0]) + '.f[4]',
                          kft=False,
                          ls=(lit_extrude_Z, lit_extrude_y - 0.2, 0))
    cmds.polyExtrudeFacet(str(rpied[0]) + '.f[4]', kft=False, ltz=-0.2)
    cmds.polyBevel3(offset=0.05)
    cmds.parent(pied, gName, relative=True)

    #coussin

    coussin = cmds.polyCube(h=0.7,
                            w=matela_widthz / 3.0,
                            depth=matela_widthz / 2.0)
    cmds.move(-matela_Widthx / 2.0 + 1.8, (matela_Height / 2.0) + 0.1,
              (matela_widthz / 2.0) / 2.0)
    cmds.polyBevel3(offset=0.3)
    cmds.polySmooth(divisions=2)
    coussinInstance = cmds.instance(coussin)
    cmds.move(-matela_Widthx / 2.0 + 1.8, (matela_Height / 2.0) + 0.1,
              (-matela_widthz / 2.0) / 2.0)
    cmds.parent(coussin, gName, relative=True)
    cmds.parent(coussinInstance, gName, relative=True)
Beispiel #54
0
import random

selected_items = cmds.ls(selection=True)
if selected_items:
    shapes = cmds.listRelatives(selected_items[0], shapes=True)

for shape in shapes:

    smoothnode = cmds.polySmooth(shape)
    cmds.polyBevel(shape, offset=0.040, worldSpace=True)

    vertexPositionList = cmds.getAttr(shape + ".vrts", multiIndices=True)
    for i in vertexPositionList:
        if random.random() > 0.8:
            brick = cmds.polyCube(w=0.2 + (random.random() * 0.4),
                                  h=0.3,
                                  d=0.2 + (random.random() * 0.4))
            vtxPos = cmds.xform(str(shape) + ".pnts[" + str(i) + "]",
                                query=True,
                                translation=True,
                                worldSpace=True)
            cmds.move(vtxPos[0] + (random.random() - 0.5) * 0.1,
                      vtxPos[1] + (random.random() - 0.5) * 0.05,
                      vtxPos[2] + (random.random() - 0.5) * 0.1,
                      brick,
                      absolute=True)
            cmds.rotate((random.random() - 0.5) * 5.0,
                        (random.random() - 0.5) * 5.0,
                        (random.random() - 0.5) * 5.0, brick)

            brickShape = cmds.listRelatives(brick, shapes=True)
Beispiel #55
0
 def testAnimMeshProp(self):
     nodeName = 'polyCube'
     shapeName = 'polyCubeShape'
     MayaCmds.polyCube(name=nodeName, ch=False)
     self.setAndKeyProps(shapeName)
     self.verifyProps(nodeName, shapeName)
Beispiel #56
0
 def MoveVertex(self):
     """ move vertex position of a object """
     cmds.polyCube(n="pCube1", ch=True)
     cmds.setAttr('pCube1.pnts[3].pntx', 5.0)
Beispiel #57
0
def MakeEngine():
    car01 = []
    engine = []

    engineBody = mc.polyCylinder(ax=(1, 0, 0))
    engine.append(engineBody[0])
    mc.polyExtrudeFacet(engineBody[0] + ".f[21]", thickness=1)
    mc.scale(0.8, 0.8, 0.8, r=True)
    mc.polyExtrudeFacet(engineBody[0] + ".f[21]", thickness=6)
    mc.select(engineBody[0], r=True)
    mc.scale(2.7, 2.7, 2.7, r=True)
    mc.move(-30, 10, 0)

    engineNub01 = mc.polyCylinder()
    engine.append(engineNub01[0])
    mc.move(-18, 12, 0)

    engineNub02 = mc.polyCylinder(h=4)
    engine.append(engineNub02[0])
    mc.move(-23, 13, 0)

    engineSteam = mc.polyCylinder()
    engine.append(engineSteam[0])
    mc.scale(1.65, 1.65, 1.65)
    mc.move(-14, 12, 0)
    mc.polyExtrudeFacet(engineSteam[0] + ".f[21]", thickness=0.3)
    mc.select(engineSteam[0] + ".f[21]", r=True)
    mc.scale(1.5, 1.5, 1.5, r=True)
    mc.polyExtrudeFacet(engineSteam[0] + ".f[21]", thickness=2)

    engineCircle01 = mc.polyCylinder(ax=(1, 0, 0))
    engine.append(engineCircle01[0])
    mc.move(-24.87, 10.04, 0)
    mc.scale(0.42, 2.09, 2.09)

    engineCircle02 = mc.polyCylinder(ax=(1, 0, 0))
    engine.append(engineCircle02[0])
    mc.move(-20.27, 10.04, 0)
    mc.scale(0.42, 2.09, 2.09)

    engineCircle03 = mc.polyCylinder(ax=(1, 0, 0))
    engine.append(engineCircle03[0])
    mc.move(-16.32, 10.04, 0)
    mc.scale(0.42, 2.09, 2.09)

    engineRoof = mc.polyCube()
    engine.append(engineRoof[0])
    mc.move(-33.94, 16.68, 0)
    mc.scale(7.12, 1.21, 10.54)

    engineBox = mc.polyCube()
    engine.append(engineBox[0])
    mc.move(-33.94, 13.13, 0)
    mc.scale(5.07, 6.41, 7.51)
    mc.polyExtrudeFacet(engineBox[0] + ".f[4]")
    mc.select(engineBox[0] + ".f[4]")
    mc.scale(1, 0.45, 0.82)
    mc.move(0, 1, 0, r=True)
    mc.polyExtrudeFacet(engineBox[0] + ".f[4]")
    mc.move(-2, 0, 0, r=True)

    engineBottom = mc.polyCube()
    engine.append(engineBottom[0])
    mc.move(-34, 8.44, 0)
    mc.scale(5.07, 5.07, 5.07)

    engineBaseTop = mc.polyCube()
    engine.append(engineBaseTop[0])
    mc.move(-21.52, 7.58, 0)
    mc.scale(20, 3.01, 2.78)

    engineBaseMid = mc.polyCube()
    engine.append(engineBaseMid[0])
    mc.move(-16.04, 6.811, 0)
    mc.scale(11.26, 0.5, 5.85)

    engineBaseBottom = mc.polyCube()
    engine.append(engineBaseBottom[0])
    mc.move(-21.44, 5.69, 0)
    mc.scale(20.04, 3.06, 2)

    engineAxel = mc.polyCylinder(ax=(0, 0, 1))
    engine.append(engineAxel[0])
    mc.move(-33.64, 5.05, 0)
    mc.scale(0.374, 0.374, 2.977)

    engineAxe2 = mc.polyCylinder(ax=(0, 0, 1))
    engine.append(engineAxe2[0])
    mc.move(-26, 5.05, 0)
    mc.scale(0.374, 0.374, 2.977)

    engineAxe3 = mc.polyCylinder(ax=(0, 0, 1))
    engine.append(engineAxe3[0])
    mc.move(-17.81, 3.77, 0)
    mc.scale(0.25, 0.25, 2.977)

    engineAxe4 = mc.polyCylinder(ax=(0, 0, 1))
    engine.append(engineAxe4[0])
    mc.move(-12.25, 3.77, 0)
    mc.scale(0.25, 0.25, 2.977)

    connectorCube = mc.polyCube()
    engine.append(connectorCube[0])
    mc.move(-35.28, 3.7, 0)
    mc.scale(8.27, 1.04, 3.53)

    connectorTorus = mc.polyTorus(r=1.212, sr=0.25)
    engine.append(connectorTorus[0])
    mc.move(-40.06, 3.71, 0)

    engineGrouped = mc.group(engine)

    car01.append(engineGrouped)

    # Wheels on the engine

    daWheels = []
    whe01 = MakeWheel()
    daWheels.append(whe01)
    mc.move(-33.72, 5.05, 3.14)
    mc.rotate(0, 90, 0)

    whe02 = MakeWheel()
    daWheels.append(whe02)
    mc.move(-25.92, 5.05, 3.14)
    mc.rotate(0, 90, 0)

    whe03 = MakeWheel(radius=2.5)
    daWheels.append(whe03)
    mc.move(-17.81, 3.78, 3.14)
    mc.rotate(0, 90, 0)

    whe04 = MakeWheel(radius=2.5)
    daWheels.append(whe04)
    mc.move(-12.24, 3.78, 3.14)
    mc.rotate(0, 90, 0)

    wheelsRight = mc.group(daWheels)
    wheelsLeft = mc.duplicate(rr=True, ic=True)
    mc.move(0, 0, -6.2, r=True)

    car01.append(wheelsRight)
    car01.extend(wheelsLeft)

    finalEngine = mc.group(car01, n="Engine")
    mc.move(0,
            -8.596468,
            0,
            finalEngine + '.scalePivot',
            finalEngine + '.rotatePivot',
            r=True)

    return finalEngine
 def CreateAni(self, *args):
     #创建cube
     if mc.objExists("myAniCube"):
         mc.delete("myAniCube")
     self._myCube = mc.polyCube(n="myAniCube")[0]
     f = open(self._dateFileName)  # 返回一个文件对象
     line = f.readline()  # 调用文件的 readline()方法
     FrameValue = 0
     SecTime = 0
     rotaFV = ""
     while line:
         #print line                 # 后面跟 ',' 将忽略换行符
         # print(line, end = '')   # 在 Python 3中使用
         if line.find("Index") >= 0:
             #读取帧数,并设置帧数
             FrameFL = re.findall(r"Index:(.+?),", line)
             if FrameFL:
                 FrameNum = int(FrameFL[0])
                 if FrameNum % 4 == 0:
                     FrameValue += 1
                     mc.currentTime(FrameValue, u=False)
                     #读取旋转值,并旋转
                     rotaFV = re.findall(r"\((.+?)\)", line)
                     if rotaFV:
                         rotaFL = rotaFV[0].split(",")
                         mc.rotate(rotaFL[0],
                                   -float(rotaFL[1]),
                                   rotaFL[2],
                                   self._myCube,
                                   a=True)
                         mc.setKeyframe("%s.rotate" % self._myCube)
                         #设置位置值
                         if self._tranDVBG:
                             mc.move(0,
                                     0,
                                     self._TranValue *
                                     self._tranDVBG[FrameValue - 1],
                                     self._myCube,
                                     r=True,
                                     os=True,
                                     wd=True)
                         else:
                             mc.move(0,
                                     0,
                                     self._TranValue,
                                     self._myCube,
                                     r=True,
                                     os=True,
                                     wd=True)
                         mc.setKeyframe("%s.t" % self._myCube)
         elif line.find("save") >= 0:
             SecTime += 1
             # print SecTime
         else:
             pass
         line = f.readline()
     f.close()
     tmpSnap = []
     tmpSnapShape = ""
     if FrameValue >= 1:
         mc.playbackOptions(min=1, ast=1, max=FrameValue, aet=FrameValue)
         tmpSnap = mc.snapshot(self._myCube,
                               mt=True,
                               startTime=0,
                               endTime=FrameValue,
                               increment=1)
         tmpSnapShape = mc.listRelatives(tmpSnap[0])[0]
         print tmpSnapShape
         mc.setAttr("%s.showFrames" % tmpSnapShape, 1)
         mc.currentTime(1, u=True)
Beispiel #59
0
 def setUp(self):
     cmds.file(new=True, force=True)
     self.bs = map(lambda _: cmds.polySphere()[0], xrange(10))
     self.cs = map(lambda _: cmds.polyCube()[0], xrange(10))
     cmds.select(None)
Beispiel #60
0
import maya.cmds as cmd

cmd.polyCube()