Exemplo n.º 1
0
    def setUp(self):
        self.config = {
            "movePolicy":
            "merge",
            "proxyPolicy":
            "index",
            "map": [["shoulder_ik", "armUI_R0_ctl", "armUI_L0_ctl", 0],
                    ["shoulder_rotRef", "armUI_R0_ctl", "armUI_L0_ctl", 0],
                    ["shoulder_rotRef", "armUI_R1_ctl", "armUI_L0_ctl", 0]]
        }

        self.pcs = pm.polyCube(n="armUI_R0_ctl")
        self.pcs2 = pm.polyCube(n="armUI_R1_ctl")
        self.pct = pm.polyCube(n="armUI_L0_ctl")
        att.addAttribute(self.pcs[0],
                         "shoulder_ik",
                         "double",
                         0,
                         minValue=0,
                         maxValue=1)
        ch2 = att.addAttribute(self.pcs[0],
                               "shoulder_rotRef",
                               "double",
                               0,
                               minValue=0,
                               maxValue=1)
        ch3 = att.addAttribute(self.pcs2[0],
                               "shoulder_rotRef",
                               "double",
                               0,
                               minValue=0,
                               maxValue=1)
        pm.connectAttr(ch2, self.pcs[0].ty)
        pm.connectAttr(ch3, self.pcs2[0].ty)
Exemplo n.º 2
0
def test_unsaved_changes(maya_engine, empty_file):
    assert maya_engine.has_unsaved_changes() == False

    # do some changes
    pm.polyCube()

    assert maya_engine.has_unsaved_changes() == True
Exemplo n.º 3
0
    def setUp(self):
        self.temp = tempfile.mkdtemp(prefix='referencesTest')
        print "created temp dir: %s" % self.temp

        # Refs:
        #  sphere.ma
        #    (no refs)
        #  cube.ma
        #    :sphere => sphere.ma
        #  cone.ma
        #    :cubeInCone => cube.ma
        #      :cubeInCone:sphere => sphere.ma
        #  master.ma
        #    :sphere1 => sphere.ma
        #    :sphere2 => sphere.ma
        #    :cube1 => cube.ma
        #      :cube1:sphere => sphere.ma
        #    :cone1 => cone.ma
        #      :cone1:cubeInCone => cube.ma
        #        :cone1:cubeInCone:sphere => sphere.ma

        # create sphere file
        print "sphere file"
        #        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs(os.path.join(self.temp, 'sphere.ma'), f=1)

        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference(self.sphereFile, namespace='sphere')
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs(os.path.join(self.temp, 'cube.ma'), f=1)

        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference(self.cubeFile, namespace='cubeInCone')
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs(os.path.join(self.temp, 'cone.ma'), f=1)

        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference(self.sphereFile,
                                             namespace='sphere1')
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference(self.sphereFile,
                                             namespace='sphere2')
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference(self.cubeFile, namespace='cube1')
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference(self.coneFile, namespace='cone1')
        self.masterFile = pm.saveAs(os.path.join(self.temp, 'master.ma'), f=1)
Exemplo n.º 4
0
def source_nodes():
    cmds.file(new=True, force=True)

    pcs = pm.polyCube(name="armUI_R0_ctl")
    pcs2 = pm.polyCube(name="armUI_R1_ctl")
    attribute.addAttribute(pcs[0],
                           "shoulder_ik",
                           "double",
                           0,
                           minValue=0,
                           maxValue=1)
    ch2 = attribute.addAttribute(pcs[0],
                                 "shoulder_rotRef",
                                 "double",
                                 0,
                                 minValue=0,
                                 maxValue=1)
    ch3 = attribute.addAttribute(pcs2[0],
                                 "shoulder_rotRef",
                                 "double",
                                 0,
                                 minValue=0,
                                 maxValue=1)
    pm.connectAttr(ch2, pcs[0].ty)
    pm.connectAttr(ch3, pcs2[0].ty)
Exemplo n.º 5
0
def create_collider(flaps, radius):
    '''
    Create collision geometry for combined flaps.

    :param flaps: Combined flaps geometry
    :param radius: Radius of inner wheel allows us to estimate collider geo
    '''

    tx = flaps.boundingBox().width() * 0.5
    ty = flaps.boundingBox().height() * 0.505 - radius
    tz = radius * 1.08
    tz2 = radius * 1.15
    cubea, cubea_shape = pm.polyCube(width=0.2, height=0.05, depth=0.05)
    cubeb, cubeb_shape = pm.polyCube(width=0.2, height=0.05, depth=0.05)
    cubec, cubec_shape = pm.polyCube(width=0.2, height=0.05, depth=0.05)
    cubed, cubed_shape = pm.polyCube(width=0.2, height=0.05, depth=0.05)
    cubea.setTranslation([tx, ty, tz])
    cubeb.setTranslation([-tx, ty, tz])
    cubec.setTranslation([tx, -ty, -tz2])
    cubed.setTranslation([-tx, -ty, -tz2])
    merge_verts(cubea, 7, 5)
    merge_verts(cubea, 6, 4)
    merge_verts(cubeb, 7, 5)
    merge_verts(cubeb, 6, 4)
    merge_verts(cubec, 3, 1)
    merge_verts(cubec, 2, 0)
    merge_verts(cubed, 3, 1)
    merge_verts(cubed, 2, 0)
    collider = pm.polyUnite(
        [cubea, cubeb, cubec, cubed],
        ch=False,
        mergeUVSets=True,
        name=flaps.replace('geo', 'collider_geo')
    )[0]
    return collider
Exemplo n.º 6
0
def make_cube():
    """
    Example function that will make a cube named Nisse

    :return:
    """
    pm.polyCube(name="Nisse")
Exemplo n.º 7
0
 def create(self, startLocation=[0, 0, 0]):
     try:
         py.delete(tempConnectorName)
     except:
         pass
     py.polyCube(n=tempConnectorName,
                 height=100,
                 width=100,
                 depth=10,
                 subdivisionsWidth=3,
                 subdivisionsHeight=3)
     py.setAttr(tempConnectorName + '.rz',
                lock=True,
                keyable=False,
                channelBox=False)
     py.scale(tempConnectorName + '.f[4]', (0.25, 0.25, 0.25))
     py.polyExtrudeFacet(tempConnectorName + '.f[4]', localTranslateZ=10)
     py.polyExtrudeFacet(tempConnectorName + '.f[4]',
                         localScale=(1.25, 1.25, 1.25))
     py.polyExtrudeFacet(tempConnectorName + '.f[4]', localTranslateZ=20)
     py.scale(tempConnectorName + '.f[4]', (0, 0, 1))
     py.polyExtrudeFacet(tempConnectorName + '.f[32]',
                         localScale=(0.3, 0.27, 1))
     py.polyExtrudeFacet(tempConnectorName + '.f[32]', localTranslateZ=3)
     py.polyExtrudeFacet(tempConnectorName + '.f[32]',
                         localScale=(1.25, 1.25, 1.25))
     py.polyExtrudeFacet(tempConnectorName + '.f[32]', localTranslateZ=5)
     py.scale(tempConnectorName + '.f[32]', (0, 1, 0))
     py.move(tempConnectorName + '.f[32]', (0, 0, 6.15), r=True)
     py.xform(tempConnectorName, pivots=(0, -50, -5))
     py.move(tempConnectorName, startLocation)
     py.select(tempConnectorName)
Exemplo n.º 8
0
def FUCBoxCreator():
    pos = [0, 0, 0]
    thisW = 1
    thisH = 1
    thisD = 1

    try:
        pm.select('FUC_Box')
        pos = cmds.objectCenter('FUC_Box', gl=True)
        thisW = pm.getAttr('FUC_Box' + '.sx')
        thisH = pm.getAttr('FUC_Box' + '.sy')
        thisD = pm.getAttr('FUC_Box' + '.sz')
        pm.delete()
    except:
        pass

    try:
        pm.select('FUC_Sphere')
        posX = pm.getAttr('FUC_Sphere' + '.tx')
        posY = pm.getAttr('FUC_Sphere' + '.ty')
        posZ = pm.getAttr('FUC_Sphere' + '.tz')
        pos = [posX, posY, posZ]
        r = pm.getAttr('FUC_Sphere' + '.sx')
        thisW = r
        thisH = thisW
        thisD = thisW
        pm.delete()
    except:
        pass

    pm.polyCube(name='FUC_Box', w=1, h=1, d=1)
    pm.move(pos)
    pm.scale(thisW, thisH, thisD)
    mel.eval('setAttr "FUC_Box.overrideEnabled" 1;')
    mel.eval('setAttr "FUC_Box.overrideShading" 0;')
Exemplo n.º 9
0
    def setUp(self):
        self.temp = tempfile.mkdtemp(prefix='referencesTest')
        print "created temp dir: %s" % self.temp

        # Refs:
        #  sphere.ma
        #    (no refs)
        #  cube.ma
        #    :sphere => sphere.ma
        #  cone.ma
        #    :cubeInCone => cube.ma
        #      :cubeInCone:sphere => sphere.ma
        #  master.ma
        #    :sphere1 => sphere.ma
        #    :sphere2 => sphere.ma
        #    :cube1 => cube.ma
        #      :cube1:sphere => sphere.ma
        #    :cone1 => cone.ma
        #      :cone1:cubeInCone => cube.ma
        #        :cone1:cubeInCone:sphere => sphere.ma

        # create sphere file
        print "sphere file"
#        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs( os.path.join( self.temp, 'sphere.ma' ), f=1 )

        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference( self.sphereFile, namespace='sphere' )
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs( os.path.join( self.temp, 'cube.ma' ), f=1 )

        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference( self.cubeFile, namespace='cubeInCone' )
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs( os.path.join( self.temp, 'cone.ma' ), f=1 )

        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference( self.sphereFile, namespace='sphere1' )
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference( self.sphereFile, namespace='sphere2' )
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference( self.cubeFile, namespace='cube1' )
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference( self.coneFile, namespace='cone1' )
        self.masterFile = pm.saveAs(os.path.join(self.temp, 'master.ma'), f=1)
def test_getPositions2():
    # Basic world position test
    cube1 = pm.polyCube()[0]
    cube2 = pm.polyCube()[0]
    cube1.setParent(cube2)
    cube2.t.set(1, 3, 4)
    cube1.t.set(1, 2, 3)

    mat = pm.dt.Matrix()
    mat[3] = [2, 5, 7, 1]
    foundMats = mmo.getNodePositions([cube1])
    assert (flattenMat(foundMats[0]) == pytest.approx(flattenMat(mat)))
Exemplo n.º 11
0
def feetctrl(arg):
	value=pm.textField('cmm',q=True,tx=True)
	ctrsel = ["Ankle_L","ToesEnd_L","Ankle_R","ToesEnd_R"]
	fmsel = []
	fmseladjust = ["footmask_LB","footmask_LF","footmask_RB","footmask_RF"]
	LBcube = pm.polyCube(n="footmask_LB",w=0.13,h=0.03,d=0.2)
	pm.move(0.095,-0.015,0.013)
	fmsel.append(LBcube)
	LFcube = pm.polyCube(n="footmask_LF",w=0.13,h=0.03,d=0.08)
	pm.move(0.095,-0.015,0.143)
	fmsel.append(LFcube)
	RBcube = pm.polyCube(n="footmask_RB",w=0.13,h=0.03,d=0.2)
	pm.move(-0.095,-0.015,0.013)
	fmsel.append(RBcube)
	RFcube = pm.polyCube(n="footmask_RF",w=0.13,h=0.03,d=0.08)
	pm.move(-0.095,-0.015,0.143)
	fmsel.append(RFcube)
	
	fmselNew = [i for i in fmseladjust if i not in fmsel]
	AiUNode = pm.shadingNode("aiUtility",asShader=True)
	SGNode = pm.createNode("shadingEngine")
	pm.setAttr(AiUNode+".hardwareColor",0,1,1)
	pm.setAttr(AiUNode+".shadeMode",2)
	for i in range(0,len(fmselNew)):
	    shapeNode = pm.listRelatives(fmselNew[i],s=True,f=True)
	    pm.defaultNavigation(source=AiUNode,destination =shapeNode[0]+".instObjGroups[0]" ,connectToExisting=True)
	    pm.setAttr(shapeNode[0]+".castsShadows",0)
	    pm.setAttr(shapeNode[0]+".receiveShadows",0)
	    pm.setAttr(shapeNode[0]+".motionBlur",0)
	    pm.setAttr(shapeNode[0]+".primaryVisibility",0)
	    pm.setAttr(shapeNode[0]+".smoothShading",0)
	    pm.setAttr(shapeNode[0]+".visibleInReflections",0)
	    pm.setAttr(shapeNode[0]+".visibleInRefractions",0)
	    pm.setAttr(shapeNode[0]+".doubleSided",0)
	    pm.setAttr(shapeNode[0]+".aiSelfShadows",0)
	    pm.setAttr(shapeNode[0]+".aiOpaque",0)
	    pm.setAttr(shapeNode[0]+".aiVisibleInDiffuse",0)
	    pm.setAttr(shapeNode[0]+".aiVisibleInGlossy",0)
	for i in range(0,len(fmselNew)):
		pm.makeIdentity(fmselNew[i],apply=True,t=1,r=1,s=1,n=0)
	pm.select(fmselNew,r=1)	
	mel.eval('DeleteHistory')
	pm.group(fmselNew,name=value+'_feetMask_g')
	pm.rename(AiUNode,value)
	for i in range(0,len(ctrsel)):
	        if pm.objExists(ctrsel[i]):
	            pm.select(ctrsel[i])
	            pm.parentConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1)
	            pm.scaleConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1)
	            pm.setAttr(fmselNew[i] + '.primaryVisibility',0)
	            pm.setAttr(fmselNew[i] + '.castsShadows',0)
	            pm.setAttr(fmselNew[i] + '.receiveShadows',0)
	            pm.rename(fmselNew[i],value +"_" + fmselNew[i])  
def test_getPositions2():
    # Basic world position test
    cube1 = pm.polyCube()[0]
    cube2 = pm.polyCube()[0]
    cube1.setParent(cube2)
    cube2.t.set(1, 3, 4)
    cube1.t.set(1, 2, 3)

    mat = pm.dt.Matrix()
    mat[3] = [2, 5, 7, 1]
    foundMats = mmo.getNodePositions([cube1])
    assert(flattenMat(foundMats[0]) == pytest.approx(flattenMat(mat)))
def test_mainClass():
    mm = mmo.MoveMyObjects()

    cube1 = pm.polyCube()[0]
    cube2 = pm.polyCube()[0]
    cube2.t.set(1, 2, 3)
    pm.select([cube1, cube2])
    mm.savePositions()
    cube2.t.set(0, 0, 0)
    mm.applyPositions()

    # Test state
    assert(list(cube2.t.get()) == [1, 2, 3])
    assert(len(mm.positions) == 2)
Exemplo n.º 14
0
def test_get_meshes_in_selection_should_handle_shapes_correctly():
    import pymel.core as pm
    from arnold_subdiv_manager.maya_abstraction_implementation import (
        MayaAbstractionImplementation, )

    pm.newFile(f=True)
    pm.camera()
    pm.polyCube()
    pm.select(["|pCube1|pCubeShape1", "|pCube1"])
    maya_abstraction = MayaAbstractionImplementation()

    meshes = maya_abstraction.get_meshes_in_selection()

    assert meshes == [Mesh("|pCube1|pCubeShape1"), Mesh("|pCube1")]
Exemplo n.º 15
0
 def setUp(self):
     self.testName = self.shortDescription()
     if (self.testName in ["proxy_channel", "proxy_channel_index", "proxy_channel_fullName"]):
         pm.displayInfo("Running: {}".format(self.testName))
         self.pcs = pm.polyCube(n="pCube_source")
         self.pcs2 = pm.polyCube(n="pCube_source2")
         self.pct = pm.polyCube(n="pCube_target")
         self.chanName = "bla_{}".format(self.testName)
         ch1 = att.addAttribute(self.pcs[0], self.chanName, "double", 0, minValue=0, maxValue=1 )
         ch2 = att.addAttribute(self.pcs2[0], self.chanName, "double", 0, minValue=0, maxValue=1 )
         pm.connectAttr(ch1, self.pcs[0].ty)
         pm.connectAttr(ch2, self.pcs2[0].ty)
     else:
         pm.displayWarning("UNKNOWN TEST ROUTINE: {}".format(self.testName))
Exemplo n.º 16
0
def test_get_meshes_in_selection_should_only_return_meshes():
    import pymel.core as pm
    from arnold_subdiv_manager.maya_abstraction_implementation import (
        MayaAbstractionImplementation, )

    pm.newFile(f=True)
    pm.camera()
    pm.polyCube()
    pm.select(["pCube1", "camera1"])
    maya_abstraction = MayaAbstractionImplementation()

    meshes = maya_abstraction.get_meshes_in_selection()

    assert meshes == [Mesh("|pCube1")]
def test_mainClass():
    mm = mmo.MoveMyObjects()

    cube1 = pm.polyCube()[0]
    cube2 = pm.polyCube()[0]
    cube2.t.set(1, 2, 3)
    pm.select([cube1, cube2])
    mm.savePositions()
    cube2.t.set(0, 0, 0)
    mm.applyPositions()

    # Test state
    assert (list(cube2.t.get()) == [1, 2, 3])
    assert (len(mm.positions) == 2)
Exemplo n.º 18
0
    def createbricks(self):

        offz = 0.0
        row = int(self.ext_sld_row.value())
        col = int(self.ext_sld_col.value())
        width = float(self.ext_sld_width.value())
        height = float(self.ext_sld_height.value())
        depth = float(self.ext_sld_depth.value())
        offset = float(self.ext_sld_offset.value())

        for i in range(0, row):
            for j in range(0, col):
                pmc.polyCube(sz=1,
                             sy=1,
                             sx=1,
                             d=depth,
                             h=height,
                             n="brick 01",
                             w=width,
                             ax=(0, 1, 0))
                pmc.polyBevel(offsetAsFraction=1,
                              segments=2,
                              autoFit=1,
                              angleTolerance=180,
                              mergeVertexTolerance=0.0001,
                              worldSpace=1,
                              smoothingAngle=30,
                              offset=offset,
                              mergeVertices=1,
                              uvAssignment=1,
                              miteringAngle=180,
                              fillNgons=1)
                # Get bounding box of cube
                minX = float(pmc.getAttr(".boundingBoxMinX"))
                minY = float(pmc.getAttr(".boundingBoxMinY"))
                maxX = float(pmc.getAttr(".boundingBoxMaxX"))
                maxY = float(pmc.getAttr(".boundingBoxMaxY"))
                off = (maxX - minX) / 2
                if i % 2 == 0:
                    offx = (maxX - minX) * j
                    offy = (maxY - minY) * i
                    cmds.move(offx, offy, 0, r=1)

                else:
                    offx = ((maxX - minX) * j) + off
                    offy = (maxY - minY) * i
                    cmds.move(offx, offy, 0, r=1)

                cmds.move(0, 0, offz, r=1)
Exemplo n.º 19
0
	def _attachRenderProxy( self, objects ):
		path = self.fileInput.text()
		proxy = []
		
		if os.path.isdir(path):
			for file in glob.glob(path+"/*.mib"):
				bipx = pm.createNode('mip_binaryproxy',n=file.split('/').pop().split('.')[0]+'_BINARYPROXY')
				bipx.object_filename.set(file)
				proxy.append(bipx)
		else:
			bipx = pm.createNode('mip_binaryproxy',n=path.split('/').pop().split('.')[0]+'_BINARYPROXY')
			bipx.object_filename.set(path)
			proxy.append( bipx )
			
		if not objects:
			for prx in proxy:
				objects.append(pm.polyCube())
				
		for arg in objects:
			if len(proxy)==0: pm.error('No proxies found in folder. Womp Womp.')
			elif len(proxy)>1:
				print 'more than one proxy'
				#turn the lo geometry shader on
				arg.miExportGeoShader.set(1)
				#connect the proxy to the lo's geo shader
				proxy[random.randint(0,len(proxy)-1)].outValue.connect(arg.miGeoShader, f=True)
			else:
				print 'one proxy'
				#turn the lo geometry shader on
				arg.miExportGeoShader.set(1)
				#connect the proxy to the lo's geo shader
				proxy.pop().outValue.connect(arg.miGeoShader, f=True)
Exemplo n.º 20
0
    def __init__(self, name='_', size=1, pos=(0, 0, 0)):
        """
		:param name: str, name of the manipulator
		:param size: int, size of the manipulator
		:param pos: list(float), position for the manipulator
		"""

        # create cube and the locator
        self.obj = pm.polyCube(name=name + '_rigHelper',
                               h=size,
                               w=size,
                               d=size)[0]

        # set the overrides color for the cube
        # based on the side
        if 'L' in name:
            self.obj.setAttr('overrideColor', 6)
        elif 'R' in name:
            self.obj.setAttr('overrideColor', 13)
        elif 'M' in name:
            self.obj.setAttr('overrideColor', 17)

        self.obj.setAttr('overrideEnabled', 1)
        self.obj.setAttr('overrideShading', 0)
        self.obj.setAttr('displayHandle', 1)

        # sets the position
        self.obj.setTranslation(pos)
Exemplo n.º 21
0
 def create_system(self):
     
     shader = pm.shadingNode('transmat', asShader= True)
     volume = pm.polyCube(name= 'fog_volume', width=40,
                                     height=40, depth=40)[0]
     
     pm.hyperShade(volume, assign= shader)
     
     parti_volume = pm.mel.eval('mrCreateCustomNode -asShader "" parti_volume;')
     pm.setAttr('%s.scatter' % (parti_volume), 1,1,1, type= 'double3' )
     
     pm.setAttr('%s.min_step_len' % (parti_volume), .03)
     pm.setAttr('%s.max_step_len' % (parti_volume), .2)
     
     pm.connectAttr('%s.outValue' % (parti_volume),
                    '%sSG.miVolumeShader' % (shader), force= True)
     
     light_node = pm.shadingNode('%s' % (self.light_types[value]),
                                                 asLight= True)
     light_node.translate.set(0,15,0)
     light_node.rotate.set(-90,0,0)
     light = pm.rename(light_node, 'fog_light')
     
     pm.connectAttr('%s.message' % (light.getShape()),
                             '%s.lights[0]' % (parti_volume), force= True)
     if self.checkBox.getValue() == 1:
         # mrCreateCustomNode -asUtility "" physical_light;
         # // Result: Connected physical_light1.message to fog_lightShape.mentalRayControls.miLightShader. // 
         phys_light = pm.mel.eval('mrCreateCustomNode -asUtility "" physical_light;')
         
         pm.connectAttr('%s.message' % (phys_light),
                  '%s.mentalRayControls.miLightShader' % (light.getShape()))
Exemplo n.º 22
0
 def test_bind_to_pyNode(self):
     ex = self.Example('cube', 45)
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     tester = ex & 'val' > bindings.bind() > (cube, 'tx')
     tester()
     assert cmds.getAttr('pCube1.tx') == 45
Exemplo n.º 23
0
 def test_pyattr_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube.rx)
     assert isinstance(ac, bindings.PyAttributeAccessor)
     ac2 = bindings.get_accessor(shape.width)
     assert isinstance(ac2, bindings.PyAttributeAccessor)
Exemplo n.º 24
0
 def test_pynode_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube, 'rx')
     assert isinstance(ac, bindings.PyNodeAccessor)
     ac2 = bindings.get_accessor(shape, 'width')
     assert isinstance(ac2, bindings.PyNodeAccessor)
Exemplo n.º 25
0
def locatorGrid(width, height, depth, offset, centered=True):
	'''Create a grid of locators to test upon
	Args:
		width (int): Width of the grid
		height (int): Height of the grid
		offset (float): Adds an offset multiplier to the locator positions
		centered (bool): determines whether it's centered in world space
	Returns (pm.PyNode): The top group of the locator grid
	Usage: locatorGrid(5,5,5,2)
	'''
	if not pm.objExists('locatorGrid'):
		grp=pm.group(em=True,n='locatorGrid')
		for d in range(0,depth):
			for w in range(0,width):
				for h in range(0,height):
					loc = pm.polyCube(w=.5, h=.5, d=.5, ch=0)[0]
					pm.move(loc,(w*offset,h*offset,d*offset), rpr=True)
					loc.setParent(grp)
					if loc.getShape().type() == "locator":
						loc.localScale.set(.2,.2,.2)
		if centered:
			pm.xform(grp, cp=1)
			pm.move(grp, (0, 0, 0), rpr=1)
			pm.makeIdentity(grp, apply=True, r=1,s=1,t=1)
		return grp
Exemplo n.º 26
0
def getSceneBound(visualize=False) :
	large = 10000000
	objs = pm.ls(assemblies=True)
	max = [-large, -large, -large]
	min = [large, large, large]
	for o in objs :
		bmax = o.getBoundingBoxMax()
		bmin = o.getBoundingBoxMin()
		for i in range(len(bmax)) :
			if bmax[i] > max[i] :
				max[i] = bmax[i]
			if bmin[i] < min[i] :
				min[i] = bmin[i]
	if visualize :
		cube = pm.polyCube()
		cshape = cube[0].getShape()
		pm.move(cshape.name()+'.vtx[0]', min[0], min[1], max[2])
		pm.move(cshape.name()+'.vtx[1]', max[0], min[1], max[2])
		pm.move(cshape.name()+'.vtx[2]', min[0], max[1], max[2])
		pm.move(cshape.name()+'.vtx[3]', max[0], max[1], max[2])
		pm.move(cshape.name()+'.vtx[4]', min[0], max[1], min[2])
		pm.move(cshape.name()+'.vtx[5]', max[0], max[1], min[2])
		pm.move(cshape.name()+'.vtx[6]', min[0], min[1], min[2])
		pm.move(cshape.name()+'.vtx[7]', max[0], min[1], min[2])
	return min, max
Exemplo n.º 27
0
 def test_pynode_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube, 'rx')
     assert isinstance(ac, bindings.PyNodeAccessor)
     ac2 = bindings.get_accessor(shape, 'width')
     assert isinstance(ac2, bindings.PyNodeAccessor)
Exemplo n.º 28
0
 def test_pyattr_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube.rx)
     assert isinstance(ac, bindings.PyAttributeAccessor)
     ac2 = bindings.get_accessor(shape.width)
     assert isinstance(ac2, bindings.PyAttributeAccessor)
Exemplo n.º 29
0
    def createProxyCube(self, targetJoint, count):
        # Create the cube of that height
        try:
            height = self.jointSystem.lengths[count]
        except IndexError:
            height = self.jointSystem.lengths[count - 1]

        cube = pm.polyCube(height=height, ch=False)[0]

        cubeMeta = ProxyCube(part=targetJoint.part.get(), side=self.side, endSuffix="Geo")
        cubeMeta.transferShape(cube)
        cube = cubeMeta.pynode
        cube.translateY.set(height * .5)

        # Freeze Transform
        libUtilities.freeze_transform(cube)

        # reset the pivot to origin
        cube.scalePivot.set([0, 0, 0])
        cube.rotatePivot.set([0, 0, 0])

        if self.flipProxyCube:
            cube.attr(self.bendAxis).set(180)
            libUtilities.freeze_rotation(cube)

        cube.rotateOrder.set(self.rotateOrder)
        # Snap the pivot of the cube to this cluster

        # Snap the cube to joint
        libUtilities.snap(cube, targetJoint)
        libUtilities.skinGeo(cube, [targetJoint])

        return cubeMeta
Exemplo n.º 30
0
def clean_scene():
    '''
    Clean up a maya scene of orphaned and unused objects
    '''
    # Delete orphaned controller tags
    controller_tags = [x for x in pm.ls(type='controller') if x.exists() and not x.controllerObject.listConnections()]
    if controller_tags:
        pm.delete(controller_tags)
        v1_core.v1_logging.get_logger().info("Scene Cleanup Deleted Controller Tags : \n{0}".format(controller_tags))

    # Delete unused shader nodes
    temp_cube = None
    try:
        # Since Maya 2020 an error is thrown when running Delete Unused Nodes if the StandardSurface default shader is unassigned
        # So we create a temporary object, assign the default StandardSurface material to it, then delete Unused and delete the sphere
        temp_cube = pm.polyCube(name="TEMP_StandardSurface_Assignment")[0]
        temp_standard_shader = pm.sets( renderable=True, noSurfaceShader=True, empty=True, name="standardSurface1SG" )
        standard_material = pm.PyNode("standardSurface1")
        standard_material.outColor >> temp_standard_shader.surfaceShader
        pm.sets(temp_standard_shader, edit=True, forceElement=temp_cube)

        pm.mel.eval('hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");')
    except Exception, e:
        v1_core.v1_logging.get_logger().info("Failed To Delete Unused Nodes:")
        v1_core.v1_logging.get_logger().info("{0}".format(e))
        pass
Exemplo n.º 31
0
	def _prep(self,args):
		basename=self.inputName.getText()
		nparticle=pm.ls(sl=True)[0]
		if not pm.objExists(self.inputBar.getText()):
			pm.error ('GEO plane doesn\'t exist')
		geo = pm.PyNode(self.inputBar.getText())
		if not isinstance(nparticle.getShape(), pm.nt.NParticle):
			pm.error('Your selection is not an nParticle object')
        #create an instancer
		tempCube=pm.polyCube(n='temp_iinst_GEO',w=.01,h=.01,d=.01,ch=0)
		

		self.instancer=pm.PyNode(pm.particleInstancer(nparticle,name=(nparticle.name().replace('_NPARTICLE','_INSTANCER')),addObject=True,object=tempCube[0],cycleStep=1,cycleStepUnits='Frames',levelOfDetail='Geometry',rotationUnits='Degrees',rotationOrder='XYZ',position='worldPosition',rotation='rotPP',scale='scalePP',objectIndex='indexPP'))

		pm.delete(tempCube)
		#group the nparticle + instancer
		group=pm.group(n=(nparticle.name().replace('_NPATICLE','_lodA_GRP')))
		nparticle.setParent(group)
		self.instancer.setParent(group)
        #nCache itR
		
		if not pm.objExists( nparticle.name().replace('_NPARTICLE','_NUCLEUS') ):
			pm.error('Nucleus doesn\'t exist!')
		nucleus = nparticle.name().replace('_NPARTICLE','_NUCLEUS')
        #delete everything unnecessary that might cause issues
		print geo, nucleus
		print 'issue?'
		pm.delete(geo, nucleus)
		print 'issue?'
		pm.select(nparticle)
		mm.eval('performCreateNclothCache 1 \"add\";')
		pm.confirmDialog(m='WARNING, DO NOT SAVE AFTER THIS STEP',t='DONT SAVE!')
Exemplo n.º 32
0
def duplicateClean(src_mesh, name=None):
    """
    Creates a "clean" duplicate of an input mesh

    Parameters
    ----------
    src_mesh : nt.Transform or nt.Mesh
        Shape to duplicate
    name : str
        Optional name for new mesh (defaults to source mesh name)

    Returns
    -------
    nt.Transform
        Transform node for duplicate mesh
    """

    src_mesh = pm.ls(src_mesh)[0]

    new_name = name or src_mesh.nodeName()

    new_mesh = pm.polyCube(name=new_name)[0]
    pm.delete(new_mesh, ch=True)

    src_mesh.outMesh.connect(new_mesh.inMesh)
    pm.transferShadingSets(src_mesh, new_mesh, sampleSpace=0, searchMethod=3)
    pm.delete(new_mesh, ch=True)

    return new_mesh
Exemplo n.º 33
0
 def test_bind_to_pyNode(self):
     ex = self.Example('cube', 45)
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     tester = ex & 'val' > bindings.bind() > (cube, 'tx')
     tester()
     assert cmds.getAttr('pCube1.tx') == 45
Exemplo n.º 34
0
    def test_build(self):
        bp = pulse.Blueprint()
        bp.rigName = 'testRig'
        bp.initializeDefaultActions()

        mainStep = bp.getStepByPath('Main')

        ctlNode = pm.polyCube(n='my_ctl')[0]

        ctlStep = pulse.BuildStep(actionId='Pulse.AnimControl')
        ctlStep.actionProxy.setAttrValue('controlNode', ctlNode)
        mainStep.addChild(ctlStep)

        self.assertTrue(len(mainStep.children) == 1)

        builder = pulse.BlueprintBuilder(bp)
        builder.start()

        self.assertTrue(builder.isFinished)
        self.assertTrue(len(builder.errors) == 0)

        rig_node = pm.ls('testRig')
        self.assertTrue(len(rig_node) == 1)

        # make sure anim control action was run
        ctlNode = pm.ls('my_ctl')[0]
        self.assertTrue(ctlNode.tx.isKeyable())
        self.assertFalse(ctlNode.v.isKeyable())
        self.assertFalse(ctlNode.rp.isKeyable())
        ctlParentNode = ctlNode.getParent()
        self.assertEqual(ctlParentNode.nodeName(), 'my_ctl_offset')

        # check top-level transforms (4 cameras + 1 rig node)
        assemblies = pm.ls(assemblies=True)
        self.assertTrue(len(assemblies) == 5)
    def get_invalid_attributes(cls, instance, compute=False):
        invalid = []

        if compute:
            # Get default arnold attributes.
            temp_transform = pc.polyCube()[0]

            for shape in pc.ls(instance, type="mesh"):
                for attr in temp_transform.getShape().listAttr():
                    if not attr.attrName().startswith("ai"):
                        continue

                    target_attr = pc.PyNode(
                        "{}.{}".format(shape.name(), attr.attrName())
                    )
                    if attr.get() != target_attr.get():
                        invalid.append(target_attr)

            pc.delete(temp_transform)

            instance.data["nondefault_arnold_attributes"] = invalid
        else:
            invalid.extend(instance.data["nondefault_arnold_attributes"])

        return invalid
Exemplo n.º 36
0
def quickDyn(spread=5, num=10, joints=False, bake=False):
    target = []
    g = py.gravity()

    for i in range(0,num):
        c = py.polyCube()
        target.append(c)
        x = rnd(-spread,spread)
        y = rnd(-spread,spread) + 10
        z = rnd(-spread,spread)
        py.move(x,y,z)
        py.rotate(x,y,z)

    s(target)
    py.rigidBody()

    for i in range(0,len(target)):
        py.connectDynamic(target[i],f=g)

    if(joints==False and bake==True):
        bakeAnimation(target)
        
    if(joints==True):
        target2 = []

        for i in range(0,len(target)):
            s(target[i])
            jnt = py.joint()
            target2.append(jnt)
            
        if(bake==True):
            bakeAnimation(target2)

        for i in range(0,len(target2)):
            unparent(target2[i])
Exemplo n.º 37
0
    def createEmitter(self, mesh, name="particleEmitter_msh"):
        #Create boundingBox of the mesh
        bbx = pm.polyEvaluate(mesh, b=True)
        cube = pm.polyCube(w=abs(bbx[0][1] - bbx[0][0]),
                           h=abs(bbx[1][1] - bbx[1][0]),
                           d=abs(bbx[2][1] - bbx[2][0]),
                           sx=1,
                           sy=1,
                           sz=1,
                           ax=(0, 1, 0),
                           cuv=4,
                           ch=0,
                           name=name)
        cube = cube[0]
        cube.setAttr("t",
                     ((bbx[0][1] + bbx[0][0]) / 2, (bbx[1][1] + bbx[1][0]) / 2,
                      (bbx[2][1] + bbx[2][0]) / 2))

        #Keep only face 1 for emit
        pm.delete([cube + ".f[2:6]", cube + ".f[0]"])

        #Connection of mesh and the emitter
        self.connectOriginaleMesh(mesh, cube)

        #Move emitter in y  in a percentage of area of face.
        face = pm.PyNode(cube + ".f[1]")
        area = face.getArea(space="world")
        pm.select(cube)
        y = pow(area, 0.1) * 100
        pm.move(0, y, 0, r=1, os=1, wd=1)
        return cube
def test_applyOneMatrix():
    cube, shape = pm.polyCube()

    # Pass through identity matrix
    mat = pm.dt.Matrix()
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))

    # Reset to identity
    cube.t.set((1, 2, 3))
    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))

    # Arbitrary matrix.
    mat = pm.dt.Matrix([
        [0.664463024389, 0.664463024389, -0.342020143326, 0.0],
        [-0.386220403522, 0.697130037317, 0.604022773555, 0.0],
        [0.639783314196, -0.269255641148, 0.719846310393, 0.0],
        [15.5773616478, 17.4065855678, 15.7988353267, 1.0]])

    mmo.applyNodePositions([mat], [cube])
    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(mat)))
Exemplo n.º 39
0
    def createEmitter(self, mesh, name="particleEmitter_msh"):
        # Create boundingBox of the mesh
        bbx = pm.polyEvaluate(mesh, b=True)
        cube = pm.polyCube(
            w=abs(bbx[0][1] - bbx[0][0]),
            h=abs(bbx[1][1] - bbx[1][0]),
            d=abs(bbx[2][1] - bbx[2][0]),
            sx=1,
            sy=1,
            sz=1,
            ax=(0, 1, 0),
            cuv=4,
            ch=0,
            name=name,
        )
        cube = cube[0]
        cube.setAttr("t", ((bbx[0][1] + bbx[0][0]) / 2, (bbx[1][1] + bbx[1][0]) / 2, (bbx[2][1] + bbx[2][0]) / 2))

        # Keep only face 1 for emit
        pm.delete([cube + ".f[2:6]", cube + ".f[0]"])

        # Connection of mesh and the emitter
        self.connectOriginaleMesh(mesh, cube)

        # Move emitter in y  in a percentage of area of face.
        face = pm.PyNode(cube + ".f[1]")
        area = face.getArea(space="world")
        pm.select(cube)
        y = pow(area, 0.1) * 100
        pm.move(0, y, 0, r=1, os=1, wd=1)
        return cube
 def test_relativeMove(self):
     cube = pm.polyCube()[0]
     pm.move(1,0,0, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1,0,0))
     pm.move(0,1,0, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1,1,0))
     pm.move(0,0,1, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1,1,1))
Exemplo n.º 41
0
def makeCube():
    """
    this is a test function. creates a cube in the scene
    :return: void
    """
    my_cube = pm.polyCube()[0]
    pm.select(my_cube, r=True)
    pass
 def test_relativeMove(self):
     cube = pm.polyCube()[0]
     pm.move(1, 0, 0, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1, 0, 0))
     pm.move(0, 1, 0, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1, 1, 0))
     pm.move(0, 0, 1, xyz=True, r=1)
     self.assertEqual(cube.getTranslation(), dt.Vector(1, 1, 1))
Exemplo n.º 43
0
 def setUp(self):
     self.parentNode, self.parentNodeName = pm.polyCube()
     self.coreNode = NodeMock()
     self.source = NodeMock()
     self.standIn = StandIn(
             coreNode=self.coreNode,
             source=self.source,
             )
Exemplo n.º 44
0
 def boxHull(self):
     sel = pm.ls(sl=True, fl=True)
     bb, cnt, transform = self._get_bounds(sel)
     hull = pm.polyCube(w=bb.width(), h=bb.height(), d=bb.depth(), n='UCX_{0}_01'.format(transform))
     hull[0].setTranslation(cnt)
     sg = pm.PyNode('initialShadingGroup')
     sg.remove(hull[0].getShape())
     hull[0].setParent(transform)
 def setUp(self):
     self.cube, self.cubeShape = pm.polyCube(
             h=20,
             d=10,
             w=5,
             n="srcCube"
             )
     self.gen = BoxGenerator(self.cube)
Exemplo n.º 46
0
 def setUp(self):
     self.parentNode, self.parentNodeName = pm.polyCube()
     self.coreNode = NodeMock()
     self.source = NodeMock()
     self.standIn = StandIn(
         coreNode=self.coreNode,
         source=self.source,
     )
Exemplo n.º 47
0
def main():
    increment = 0
    while (increment < 3):
        if increment >= 10:
            break
        cubexform, cubeshape = pmc.polyCube()
        cubexform.translateT.set(1.5 * increment)
        increment += 1
Exemplo n.º 48
0
 def testDelete(self):
     self.standIn.name = 'test'
     self.coreNode.children = ['test']
     self.source.children = ['test']
     self.standIn.node, nodeName = pm.polyCube()
     self.standIn.delete()
     eq_(len(self.coreNode.children),0)
     eq_(len(self.source.children),0)
     eq_(pm.objExists(nodeName), False)
Exemplo n.º 49
0
def createJointGeo( joints=[], constraint=False, parent=True, color=True ):
    if not joints:
        joints = pm.selected(type='joint')

    GEOs = []
    for jnt in joints:
        jnt   = pm.PyNode(jnt)
        child = jnt.getChildren( type='joint' )

        if not child: continue # 자식 조인트가 없으면 넘어감

        # 지오메트리 생성
        geo = pm.polyCube(ch=False)[0]

        #
        geo.setParent(jnt)

        geo.t.set( child[0].t.get() * 0.5 )
        geo.r.set( 0,0,0 )

        # 스케일 조정
        tr   = child[0].t.get()
        abtr = [ abs(val) for val in tr ]

        radius = jnt.radius.get() * 2
        sx = abtr[0] if abtr[0] > 0.001 else radius
        sy = abtr[1] if abtr[1] > 0.001 else radius
        sz = abtr[2] if abtr[2] > 0.001 else radius
        geo.s.set( sx,sy,sz )

        # 이름 변경
        geo.rename( jnt.name()+'_geo' )

        # 지오메트리 pivot 옮김
        copyPivot( jnt, geo )

        # transform 초기화
        pm.makeIdentity(geo, t=True, r=True, s=True, apply=True)

        if color:
            assignColorAxisShader( geo.f[4], 'x' )
            assignColorAxisShader( geo.f[1], 'y' )
            assignColorAxisShader( geo.f[0], 'z' )

        if not parent:
            geo.setParent(w=True)

        # 구속
        if constraint:
            geo.setParent(w=True)
            pm.parentConstraint(jnt,geo)
            pm.scaleConstraint(jnt,geo)

        GEOs.append(geo)

    return GEOs
Exemplo n.º 50
0
    def setUp(self):
        print "getting temp dir"
        self.temp = os.path.join(tempfile.gettempdir(), 'referencesTest')
        if not os.path.isdir(self.temp):
            os.makedirs(self.temp)
        
        # create sphere file
        print "sphere file"
#        cmds.file(new=1, f=1)
        pm.newFile(f=1)
        sphere = pm.polySphere()
        # We will use this to test failed ref edits...
        pm.addAttr(sphere, ln='zombieAttr')
        self.sphereFile = pm.saveAs( os.path.join( self.temp, 'sphere.ma' ), f=1 )
        
        # create cube file
        print "cube file"
        pm.newFile(f=1)
        pm.polyCube()
        pm.createReference( self.sphereFile, namespace='sphere' )
        pm.PyNode('sphere:pSphere1').attr('translateX').set(2)
        self.cubeFile = pm.saveAs( os.path.join( self.temp, 'cube.ma' ), f=1 )
        
        # create cone file
        print "cone file"
        pm.newFile(f=1)
        pm.polyCone()
        pm.createReference( self.cubeFile, namespace='cubeInCone' )
        pm.PyNode('cubeInCone:pCube1').attr('translateZ').set(2)
        pm.PyNode('cubeInCone:sphere:pSphere1').attr('translateZ').set(2)
        self.coneFile = pm.saveAs( os.path.join( self.temp, 'cone.ma' ), f=1 )
        
        print "master file"
        pm.newFile(f=1)
        self.sphereRef1 = pm.createReference( self.sphereFile, namespace='sphere1' )
        pm.PyNode('sphere1:pSphere1').attr('translateY').set(2)
        self.sphereRef2 = pm.createReference( self.sphereFile, namespace='sphere2' )
        pm.PyNode('sphere2:pSphere1').attr('translateY').set(4)
        self.cubeRef1 = pm.createReference( self.cubeFile, namespace='cube1' )
        pm.PyNode('cube1:sphere:pSphere1').attr('translateY').set(6)
        pm.PyNode('cube1:pCube1').attr('translateY').set(6)
        self.coneRef1 = pm.createReference( self.coneFile, namespace='cone1' )
Exemplo n.º 51
0
	def make_leaf(self):
		i = pm.polyCube(w=.5,d=1.5,h=4,sw=3,sh=3)
		pm.select(i[0].vtx[12:19])
		pm.scale(0.1,0.1,1,r=True)
		pm.select(i[0].vtx[0:3],i[0].vtx[28:31])
		pm.scale(0.1,0.1,1,r=True)
		pm.select(i[0].vtx[4],i[0].vtx[7:8],i[0].vtx[11],i[0].vtx[20],i[0].vtx[23:24],i[0].vtx[27]) 
		pm.scale(0.8,0.8,0.8)
		pm.select(i[0])
		pm.hyperShade(assign=Lsystem.leafShader)
		return i
Exemplo n.º 52
0
    def makeCube(self, nameOverride = 'newProxy'):
        currentScale = self.obj.scale.get()
        currentTrans = self.obj.translate.get()
        currentRotate = self.obj.rotate.get()
        # set object transforms to init
        self.obj.scale.set((1,1,1))
        self.obj.rotate.set((0,0,0))
        self.obj.translate.set((0,0,0))

        boundingBox = pm.exactWorldBoundingBox(self.obj)

        # return object to where it was
        self.obj.scale.set(currentScale)
        self.obj.rotate.set(currentRotate)
        self.obj.translate.set(currentTrans)

        height = (boundingBox[4]-boundingBox[1])
        cube = pm.polyCube(width=(boundingBox[3]-boundingBox[0]),
                            height=height,
                            depth=(boundingBox[5]-boundingBox[2]),
                            name=nameOverride + '_box'
                            )[0]

        cube.translate.set(0,height / 2, 0)
        # freeze cube transforms
        pm.makeIdentity(cube, a=1, t=1)

        # create an arrow showing the direction of
        # front rotation
        arrow = pm.curve(
                d=1,
                p=[
                    (-2, 0, 0),
                    (-2, 0, 6),
                    (-4, 0, 6),
                    (0, 0, 10),
                    (4, 0, 6),
                    (2, 0, 6),
                    (2, 0, 0)
                ],
                k=[0,1,2,3,4,5,6],
                n=nameOverride
        )
        pm.parent(cube, arrow)
        # add the cube to display layer
        self.addToDisplayLayer(cube)

        arrow.rotate.set(currentRotate)
        arrow.scale.set(currentScale)
        arrow.translate.set(currentTrans)

        # parent the cube to the arrow

        return (arrow, arrow.name())
def getMultiMatrixObjects():
    cubes = [pm.polyCube()[0] for x in xrange(4)]

    # Just some translation matrices, other tests can check rotation
    # This test should check that we touch the correct objects, and
    # fail otherwise.
    mats = []
    for x in xrange(4):
        mat = pm.dt.Matrix()
        mat[3] = (x, x + 1, x + 2, 1)
        mats.append(mat)
    return cubes, mats
def test_duplicate():
    cube, shape = pm.polyCube()
    cube.t.set((1, 2, 3))
    cube.r.set((20, 30, 40))
    cube.rx.lock()
    cube.rx.setKeyable(False)

    group = mmo.duplicateGroup(cube, 'my_cube')
    assert (group.nodeName() == 'my_cube')
    assert (list(group.t.get()) == pytest.approx([1.0, 2.0, 3.0]))
    assert (list(group.r.get()) == pytest.approx([20.0, 30.0, 40.0]))
    for attr in 't r s tx ty tz rx ry rz sx sy sz v'.split():
        assert (not group.attr(attr).isLocked())
        assert (group.attr(attr).isKeyable())
Exemplo n.º 55
0
    def testStoreMeta(self):
        self.standIn.node, nodeName = pm.polyCube()
        self.source.coreD = {
                "prefix":"testPrefix",
                "meshes":"testKeyable",
                }

        self.standIn.storeMeta()

        data = self.standIn.node.getAttr("characterCrowd")
        eq_(
            '{"source": "testName", "prefix": "testPrefix", "meshes": "testKeyable"}',
                data)
        pm.delete(nodeName)
def test_applyLocked():
    cube, shape = pm.polyCube()
    cube.tx.lock()


    applyMat = pm.dt.Matrix()
    resultMat = pm.dt.Matrix()
    applyMat[3] = (5, 5, 5, 1)
    # Tests partial application of position
    resultMat[3] = (0, 5, 5, 1)
    mmo.applyNodePositions([applyMat], [cube])

    cubeMat = flattenMat(cube.getMatrix(worldSpace=True))
    assert(cubeMat == pytest.approx(flattenMat(resultMat)))
Exemplo n.º 57
0
def test_selectKeyable():

    g = TestGui()

    g.parentItem = pm.polyCube()[0]
    firstCube = pm.polyCube()[0]
    secondCube = pm.polyCube()[0]
    g.selectedKeyable = LabelMock()
    pm.select(firstCube, secondCube)

    sel = pm.ls(sl=1)
    l = len(sel)
    eq_(l,2)
    g.selectKeyable()

    eq_("3 (pCube2...)", g.selectedKeyable.text)

    keyableAttrs = g.keyable

    eq_(len(keyableAttrs), 30)

    eq_(str(keyableAttrs[0]), 'pCube2.visibility')

    pm.delete(firstCube, secondCube, g.parentItem)
Exemplo n.º 58
0
def create_boxes():
    boxes = []
    for jnt in pymel.ls(type='joint'):
        joint_data = JointData(jnt)
        if joint_data.is_valid():
            length = joint_data.length
            transform, make = pymel.polyCube(height=length, width=length*0.33, depth=length*0.33)
            r_offset = pymel.datatypes.Matrix(0, -1.0, -0.0, 0.0, 1.0, 0, 0.0, 0.0, 0.0, -0.0, 1.0, 0.0,
                                              joint_data.dir[0]*length*0.5,
                                              joint_data.dir[1]*length*0.5,
                                              joint_data.dir[2]*length*0.5,
                                              1.0)
            cylinder_tm = r_offset
            transform.setParent(jnt)
            transform.setMatrix(cylinder_tm)
            boxes.append(transform)
    return boxes