Ejemplo n.º 1
0
 def test_assertConstrained(self):
     a = cmds.polySphere()[0]
     b = cmds.polySphere()[0]
     
     temp = cmds.parentConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a, b, type='parent') )
     cmds.delete(temp)
     
     temp = cmds.aimConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a, b, type='aim') )
     cmds.delete(temp)        
     
     temp = cmds.pointConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a, b, type='point') )
     cmds.delete(temp)  
     
     temp = cmds.orientConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a,b,type='orient') )
     cmds.delete(temp)      
     
     temp = cmds.scaleConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a,b,type='scale') )
     cmds.delete(temp)    
     
     temp = cmds.geometryConstraint(a,b)
     self.assertTrue( self.lib.assertConstrained(a,b,type='geometry') )
     cmds.delete(temp)       
     
     try:
         self.lib.assertConstrained(a,b,type='parent')
     except AssertionError:
         pass
Ejemplo n.º 2
0
def make_shape(type, name, divisions):
    """
    Creates shape based on argument passed

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

    if type == 'cube':
        mc.polyCube(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cone':
        mc.polyCone(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'cylinder':
        mc.polyCylinder(n=name, sx=divisions, sy=divisions, sz=divisions)
    elif type == 'plane':
        mc.polyPlane(n=name, sx=divisions, sy=divisions)
    elif type == 'torus':
        mc.polyTorus(n=name, sx=divisions, sy=divisions)
    elif type == 'sphere':
        mc.polySphere(n=name, sx=divisions, sy=divisions)
    else:
        mc.polySphere()
Ejemplo n.º 3
0
	def HI(self):
            if self.checkSphere.isChecked():
                cmds.polySphere()
            if self.checkTorus.isChecked():
                cmds.polyTorus()
            if self.checkCube.isChecked():
                cmds.polyCube()
            pass
Ejemplo n.º 4
0
def snapToMeshTest():
    inMeshT = cmds.polySphere()
    inMesh = cmds.listRelatives(inMeshT[0], fullPath = True, shapes = True)
    print inMesh
    outObj = cmds.polySphere(radius = 0.1)
    ctrl = cmds.circle(r=0.5, n="cn_arm_fk_ctrl");
    cmds.move(1,0,0,ctrl)
    snapToMesh(inMesh = inMesh[0], outObj = outObj[0], ctrlObj=ctrl[0])
Ejemplo n.º 5
0
    def _setup_plugin(self):
        collider = cmds.polySphere()[0]
        target = cmds.polySphere(subdivisionsAxis=20,
                                 subdivisionsHeight=20)[0]
#         target = cmds.polyCube()
        plugin = cmds.deformer(target, type=self.name)[0]
        cmds.connectAttr('%s.worldInverseMatrix' % collider,
                         '%s.volumeInverseMatrix' % plugin)
Ejemplo n.º 6
0
	def HI(self):
            if self.checkSphere.isChecked():
                cmds.polySphere()
            if self.checkTorus.isChecked():
                cmds.polyTorus()
            if self.checkCube.isChecked():
                cmds.polyCube()
            pass
Ejemplo n.º 7
0
    def createRig(self):
        # Create a Cube for test cases
        mc.polySphere(name='mySphere')
        objCenter = mc.objectCenter('mySphere', l=True)

        # Get the bounding box for the selected ojbject
        XYZ = mc.xform('mySphere', bb=True, q=True)
        rad = XYZ[3] / 2 * self.settings.radius
        strltPos = self.settings.lightPos
        lightP = 0.0

        if strltPos == "High":
            lightP = 5.0
        elif strltPos == "Low":
            lightP = -5.0
        else:
            lightP = 0.0

        # Create a circle to place three point lights
        mc.circle(n='curveLights', nr=(0, 1, 0), c=(0, 0, 0), sections=9, radius=rad)

        # Create lights in three positions on the curve
        loc = mc.pointOnCurve('curveLights', pr=0.0, p=True)
        #_item = mc.spotLight(name='FillLight', coneAngle=45)
        _item = self.createLight(self.fillLight, "FillLight")
        mc.move(loc[0], loc[1]+lightP, loc[2], _item, ls=True)

        loc = mc.pointOnCurve('curveLights', pr=3.0, p=True)
        #_item = mc.spotLight(name='KeyLight', coneAngle=45)
        _item = self.createLight(self.keyLight, "KeyLight")
        mc.move(loc[0], loc[1]+lightP, loc[2], _item, ls=True)

        loc = mc.pointOnCurve('curveLights', pr=6.0, p=True)
        #_item = mc.spotLight(name='RimLight', coneAngle=45)
        _item = self.createLight(self.rimLight, "RimLight")
        mc.move(loc[0], loc[1]+lightP, loc[2], _item, ls=True)

        # Create space locator and aimConstraints
        mc.spaceLocator(n='fillLocator', p=(objCenter[0], objCenter[1], objCenter[2]))
        mc.aimConstraint('fillLocator', 'FillLight', aimVector=(0.0, 0.0, -1.0))
        mc.parent('fillLocator', 'curveLights', relative=True)

        mc.spaceLocator(n='keyLocator', p=(objCenter[0], objCenter[1], objCenter[2]))
        mc.aimConstraint('keyLocator', 'KeyLight', aimVector=(0.0, 0.0, -1.0))
        mc.parent('keyLocator', 'curveLights', relative=True)

        mc.spaceLocator(n='rimLocator', p=(objCenter[0], objCenter[1], objCenter[2]))
        mc.aimConstraint('rimLocator', 'RimLight', aimVector=(0.0, 0.0, -1.0))
        mc.parent('rimLocator', 'curveLights', relative=True)

        # Create lights main locator
        mc.spaceLocator(n='lightsMainLocator', p=(objCenter[0], objCenter[1], objCenter[2]))
        mc.parent('FillLight', 'lightsMainLocator', relative=True)
        mc.parent('KeyLight', 'lightsMainLocator', relative=True)
        mc.parent('RimLight', 'lightsMainLocator', relative=True)

        # Create Main Group for the entire light rig
        mc.group('curveLights', 'lightsMainLocator', n='LightRigGroup')
Ejemplo n.º 8
0
def diamondLattice(dimX=1, dimY=1, dimZ=1, radiusBall = 0.1, radiusStick = 0.02, latticeConst = 1.0, sticks = True):
  
    for x in xrange (0, dimX + 1):
        for y in xrange (0, dimY + 1):
            for z in xrange (0, dimZ + 1):

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

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

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

                diamondTranslations = [(xCoordDia25, yCoordDia25, zCoordDia25), (xCoordDia75, yCoordDia75, zCoordDia25), (xCoordDia25, yCoordDia75, zCoordDia75), (xCoordDia75, yCoordDia25, zCoordDia75)]
                
                for i in xrange(0, 4):
                    if x != dimX and y != dimY and z != dimZ:
                        # 1/4 balls
                        nameDiaBall = 'diaBall' + str(i) + nameSuffix
                        cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameDiaBall)
                        cmds.setAttr(str(nameDiaBall)+'.translate', diamondTranslations[i][0], diamondTranslations[i][1], diamondTranslations[i][2])
                        
                        # bonds between lattice points
                        if sticks == True:
                            axes = [(-1, -1, -1), (1, 1, -1), (-1, 1, 1), (1, -1, 1)]
                            heightDia = math.sqrt(3) * 0.25 * latticeConst
                        
                            for j in xrange(0, 4):
                                #diamond sticks                
                                nameDiaStick = 'diaStick' + str(i) + str(j) + '_' + nameSuffix
                                cmds.polyCylinder(r=radiusStick, h=heightDia, sx=5, n=nameDiaStick, axis=axes[i])
                                cmds.setAttr(str(nameDiaStick)+'.translate', diamondTranslations[j][0] + 0.125*axes[i][0], diamondTranslations[j][1] + 0.125*axes[i][1], diamondTranslations[j][2] + 0.125*axes[i][2])
Ejemplo n.º 9
0
def prepareBaseMesh():
    ''' Initialize the base mesh with the proper Paintable Attribute on its Shape Node, as well as generate the Control Sphere and vertex graph. '''

    if mc.attributeQuery('growthWeights', node=baseMeshShape,
                         exists=True) == False:
        mc.addAttr(baseMeshShape,
                   ln='growthWeights',
                   nn='GrowthWeights',
                   dt='doubleArray')

    mc.makePaintable('mesh', 'growthWeights', at='doubleArray')

    # Create the control sphere and assign it a semi-transparent material
    if mc.objExists(controlSphereName) == False:
        mc.polySphere(n=controlSphereName, r=1)
        semitransparentMaterial = mc.shadingNode('blinn', asShader=True)
        mc.setAttr(semitransparentMaterial + '.transparency',
                   0.3,
                   0.3,
                   0.3,
                   type='double3')
        mc.select(controlSphereName)
        mc.hyperShade(a=semitransparentMaterial)

    mSel = om.MSelectionList()
    mSel.add(baseMeshName)
    om.MGlobal.getActiveSelectionList(mSel)
    dagPath = om.MDagPath()
    component = om.MObject()
    mSel.getDagPath(0, dagPath, component)

    # Get positions of all vertices on the mesh
    meshFn = om.MFnMesh(dagPath)
    positions = om.MPointArray()
    meshFn.getPoints(positions, om.MSpace.kWorld)

    # Iterate and calculate vectors based on connected vertices
    iter = om.MItMeshVertex(dagPath, component)
    connectedVertices = om.MIntArray()
    checkedNodes = [False] * positions.length()

    # Initialize the graph with the base mesh's vertices
    while not iter.isDone():
        curVertexID = iter.index()
        checkedNodes[curVertexID] = True

        g.addVertex(curVertexID)
        iter.getConnectedVertices(connectedVertices)

        for i in range(connectedVertices.length()):
            neighbourID = connectedVertices[i]
            if checkedNodes[neighbourID] == False:
                g.addVertex(neighbourID)
                g.addEdge(
                    curVertexID, neighbourID,
                    squareDistance(positions[curVertexID],
                                   positions[neighbourID]))
        iter.next()
Ejemplo n.º 10
0
def scBalls(x, y, z, radiusBall, latticeConst):
    xCoord = x * latticeConst
    yCoord = y * latticeConst
    zCoord = z * latticeConst
    nameSuffix = str(x) + str(y) + str(z)

    nameBall = 'ball' + nameSuffix
    cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameBall)
    cmds.setAttr(str(nameBall) + '.translate', xCoord, yCoord, zCoord)
Ejemplo n.º 11
0
def scBalls(x, y, z, radiusBall, latticeConst):
        xCoord = x*latticeConst
        yCoord = y*latticeConst
        zCoord = z*latticeConst
        nameSuffix = str(x) + str(y) + str(z)
        
        nameBall = 'ball' + nameSuffix
        cmds.polySphere(sx=10, sy=10, r=radiusBall, n=nameBall)
        cmds.setAttr(str(nameBall)+'.translate', xCoord, yCoord, zCoord)
Ejemplo n.º 12
0
def create_nhair_test_scene():
    cmds.file(new=True, force=True)
    curves = []
    for points in curve_datas:
        curves.append(cmds.curve(p=points))

    cmds.polySphere()
    cmds.select(curves, add=True)
    mel.eval('makeCurvesDynamic 2 { "1", "1", "1", "1", "0"};')
Ejemplo n.º 13
0
def QC_FunctionalTest1():
    # Resets everything
    QC_TestResetScene()
    QC_TestResetHypershade()
    # Creates a sphere
    cmds.polySphere(n='Object001')
    cmds.select('Object001')
    # Runs the script
    QC_QuickChecker()
Ejemplo n.º 14
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
Ejemplo n.º 15
0
 def doIt(self,argList):
     cmds.polyPlane(n='myPlane', h=5, w=2)
     cmds.polySphere(n='mySphere', r=5)
     cmds.select('mySphere')
     cmds.move(0,5,0)
     cmds.rigidBody( n='myRigidBody', active=True, b=0.5, sf=0.4 )
     cmds.select(cl=True)
     cmds.gravity(n='myGravity')
     cmds.connectDynamic('mySphere', fields='myGravity')
Ejemplo n.º 16
0
def createBoudingSphere(object):

    bbox = cmds.xform(object, bb=True, q=True)
    centerPosition = [(bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2,
                      (bbox[2] + bbox[5]) / 2]
    size = max(bbox[3] - bbox[0], bbox[4] - bbox[1], bbox[5] - bbox[2])
    sphereName = object + '_bSphere'
    cmds.polySphere(n=sphereName, r=size / 2)
    cmds.xform(sphereName, translation=centerPosition, ws=True)
Ejemplo n.º 17
0
def MyGeo(geo):
    
    if geo == "cube":
        cmds.polyCube(w=10, h=3, d=3, sx=10, sy=2, sz=2, ch=1)

    elif geo == "sphere":
        cmds.polySphere(r=1, sx=20, sy=20, ch=1)

    elif geo == "torus":
        cmds.polyTorus(r=1, sr=0.5, tw=0, sx=20, sy=20, ch=1)
Ejemplo n.º 18
0
def makeSpheres(*args):
    global sphereCountField
    global sphereRadiusField

    numSpheres = cmds.intField(sphereCountField, query=True, value=True)
    myRadius = cmds.floatField(sphereRadiusField, query=True, value=True)

    for i in range(numSpheres):
        cmds.polySphere(radius=myRadius)
        cmds.move((i * myRadius * 2.2), 0, 0)
Ejemplo n.º 19
0
def RandomSphere():
    cmds.polySphere(r=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))
Ejemplo n.º 20
0
def RandomSphere():
    cmds.polySphere(r = 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))
Ejemplo n.º 21
0
def createObj():
    Opt = cmds.optionMenu('Object', query=True, select=True)
    if Opt == 1:
        cmds.polyCube()
    else:
        pass

    if Opt == 2:
        cmds.polySphere()
    else:
        pass
Ejemplo n.º 22
0
def bccLattice(dimX=1,
               dimY=1,
               dimZ=1,
               radiusBall=0.1,
               radiusStick=0.02,
               latticeConst=1.0,
               sticks=True):

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

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

                # ball in body

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

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

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

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

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

                            cmds.polyCylinder(r=radiusStick,
                                              h=heightBC,
                                              sx=5,
                                              n=nameStickBody,
                                              axis=axes[i])
                            cmds.setAttr(
                                str(nameStickBody) + '.translate', xCoordBody,
                                yCoordBody, zCoordBody)
Ejemplo n.º 23
0
def lgtSpheresCreator():
    #check render engine
    renderEngine = mc.getAttr("defaultRenderGlobals.ren")

    #create locator
    loc = mc.spaceLocator(n="Lgt_Spheres_" + str(renderEngine), p=(0, 0, 0))

    #create chromn ball
    chromnBallName = mc.polySphere(n=loc[0] + "_chromnBall")
    mc.delete(chromnBallName, ch=True)
    chromnBallShape = mc.listRelatives(chromnBallName[0], s=True)
    mc.setAttr(chromnBallShape[0] + '.castsShadows', 0)
    mc.setAttr(chromnBallShape[0] + '.receiveShadows', 0)
    mc.setAttr(chromnBallShape[0] + '.visibleInReflections', 0)
    mc.setAttr(chromnBallShape[0] + '.visibleInRefractions', 0)
    mc.setAttr(chromnBallName[0] + '.translateY', 7)
    mc.parent(chromnBallName[0], loc[0], relative=True)
    chromnBall = mc.ls(chromnBallName[0], l=True)

    #create gray ball
    grayBallName = mc.polySphere(n=loc[0] + "_grayBall")
    mc.delete(grayBallName, ch=True)
    grayBallShape = mc.listRelatives(grayBallName[0], s=True)
    mc.setAttr(grayBallShape[0] + '.castsShadows', 0)
    mc.setAttr(grayBallShape[0] + '.receiveShadows', 0)
    mc.setAttr(grayBallShape[0] + '.visibleInReflections', 0)
    mc.setAttr(grayBallShape[0] + '.visibleInRefractions', 0)
    mc.setAttr(grayBallName[0] + '.translateY', 4.5)
    mc.parent(grayBallName[0], loc[0], relative=True)
    grayBall = mc.ls(grayBallName[0], l=True)

    #create white ball
    whiteBallName = mc.polySphere(n=loc[0] + "_whiteBall")
    mc.delete(whiteBallName, ch=True)
    whiteBallShape = mc.listRelatives(whiteBallName[0], s=True)
    mc.setAttr(whiteBallShape[0] + '.castsShadows', 0)
    mc.setAttr(whiteBallShape[0] + '.receiveShadows', 0)
    mc.setAttr(whiteBallShape[0] + '.visibleInReflections', 0)
    mc.setAttr(whiteBallShape[0] + '.visibleInRefractions', 0)
    mc.setAttr(whiteBallName[0] + '.translateY', 2)
    mc.parent(whiteBallName[0], loc[0], relative=True)
    whiteBall = mc.ls(whiteBallName[0], l=True)

    #create and assign shaders by render engine
    if renderEngine == "vray":
        assignVrayShaders(chromnBall, grayBall, whiteBall)
        mc.select(loc, r=True)
    elif renderEngine == "arnold":
        assignArnoldShaders(chromnBall, grayBall, whiteBall)
        mc.select(loc, r=True)
    else:
        assignMayaShaders(chromnBall, grayBall, whiteBall)
        mc.select(loc, r=True)
Ejemplo n.º 24
0
    def testSet_noNormals_Attr(self):

        MayaCmds.polyCube(name='polyCube')
        # add the necessary props
        MayaCmds.select('polyCubeShape')
        MayaCmds.addAttr(longName='SubDivisionMesh',
                         attributeType='bool',
                         defaultValue=False)
        MayaCmds.addAttr(longName='interpolateBoundary',
                         attributeType='bool',
                         defaultValue=True)
        MayaCmds.addAttr(longName='noNormals',
                         attributeType='bool',
                         defaultValue=False)
        MayaCmds.addAttr(longName='flipNormals',
                         attributeType='bool',
                         defaultValue=False)
        MayaCmds.addAttr(longName='faceVaryingInterpolateBoundary',
                         attributeType='bool',
                         defaultValue=False)

        MayaCmds.polySphere(name='polySphere')

        # add the necessary props
        MayaCmds.select('polySphereShape')
        MayaCmds.addAttr(longName='SubDivisionMesh',
                         attributeType='bool',
                         defaultValue=False)
        MayaCmds.addAttr(longName='interpolateBoundary',
                         attributeType='bool',
                         defaultValue=True)
        MayaCmds.addAttr(longName='noNormals',
                         attributeType='bool',
                         defaultValue=True)
        MayaCmds.addAttr(longName='flipNormals',
                         attributeType='bool',
                         defaultValue=False)
        MayaCmds.addAttr(longName='faceVaryingInterpolateBoundary',
                         attributeType='bool',
                         defaultValue=False)

        #ignore facevaryingType, subdPaintLev
        MayaCmds.group('polyCube', 'polySphere', name='polygons')

        self.__files.append(
            util.expandFileName('staticPoly_noNormals_AttrTest.abc'))
        MayaCmds.AbcExport(j='-root polygons -f ' + self.__files[-1])

        # reading test
        MayaCmds.AbcImport(self.__files[-1], mode='open', debug=False)
        # make sure the noNormal attribute is set correctly when the file is loaded
        self.failIf(MayaCmds.listAttr('polyCubeShape').count('noNormals') != 0)
        self.failUnless(MayaCmds.getAttr('polySphereShape.noNormals'))
Ejemplo n.º 25
0
def createStaticSolarSystem():
    MayaCmds.file(new=True, force=True)

    moon = MayaCmds.polySphere(radius=0.5, name="moon")[0]
    MayaCmds.move(-5, 0.0, 0.0, r=1)
    earth = MayaCmds.polySphere(radius=2, name="earth")[0]
    MayaCmds.select(moon, earth)
    MayaCmds.group(name="group1")

    MayaCmds.polySphere(radius=5, name="sun")[0]
    MayaCmds.move(25, 0.0, 0.0, r=1)
    MayaCmds.group(name="group2")
Ejemplo n.º 26
0
def createStaticSolarSystem():
    MayaCmds.file(new=True, force=True)

    moon = MayaCmds.polySphere(radius=0.5, name="moon")[0]
    MayaCmds.move(-5, 0.0, 0.0, r=1)
    earth = MayaCmds.polySphere(radius=2, name="earth")[0]
    MayaCmds.select(moon, earth)
    MayaCmds.group(name='group1')

    MayaCmds.polySphere(radius=5, name="sun")[0]
    MayaCmds.move(25, 0.0, 0.0, r=1)
    MayaCmds.group(name='group2')
Ejemplo n.º 27
0
def lgtSpheresCreator():
    #check render engine
    renderEngine = mc.getAttr("defaultRenderGlobals.ren")

    #create locator
    loc = mc.spaceLocator(n = "Lgt_Spheres_"+str(renderEngine), p = (0,0,0))

    #create chromn ball
    chromnBallName = mc.polySphere(n = loc[0]+"_chromnBall")
    mc.delete(chromnBallName,ch = True)
    chromnBallShape = mc.listRelatives(chromnBallName[0], s = True)
    mc.setAttr(chromnBallShape[0]+'.castsShadows', 0)
    mc.setAttr(chromnBallShape[0]+'.receiveShadows', 0)
    mc.setAttr(chromnBallShape[0]+'.visibleInReflections', 0)
    mc.setAttr(chromnBallShape[0]+'.visibleInRefractions', 0)
    mc.setAttr(chromnBallName[0]+'.translateY', 7)
    mc.parent(chromnBallName[0], loc[0], relative = True)
    chromnBall = mc.ls(chromnBallName[0], l = True)

    #create gray ball
    grayBallName = mc.polySphere(n = loc[0]+"_grayBall")
    mc.delete(grayBallName,ch = True)
    grayBallShape = mc.listRelatives(grayBallName[0], s = True)
    mc.setAttr(grayBallShape[0]+'.castsShadows', 0)
    mc.setAttr(grayBallShape[0]+'.receiveShadows', 0)
    mc.setAttr(grayBallShape[0]+'.visibleInReflections', 0)
    mc.setAttr(grayBallShape[0]+'.visibleInRefractions', 0)
    mc.setAttr(grayBallName[0]+'.translateY', 4.5)
    mc.parent(grayBallName[0], loc[0], relative = True)
    grayBall = mc.ls(grayBallName[0], l = True)

    #create white ball
    whiteBallName = mc.polySphere(n = loc[0]+"_whiteBall")
    mc.delete(whiteBallName,ch = True)
    whiteBallShape = mc.listRelatives(whiteBallName[0], s = True)
    mc.setAttr(whiteBallShape[0]+'.castsShadows', 0)
    mc.setAttr(whiteBallShape[0]+'.receiveShadows', 0)
    mc.setAttr(whiteBallShape[0]+'.visibleInReflections', 0)
    mc.setAttr(whiteBallShape[0]+'.visibleInRefractions', 0)
    mc.setAttr(whiteBallName[0]+'.translateY', 2)
    mc.parent(whiteBallName[0], loc[0], relative = True)
    whiteBall = mc.ls(whiteBallName[0], l = True)
    
    #create and assign shaders by render engine 
    if renderEngine == "vray":
        assignVrayShaders(chromnBall,grayBall,whiteBall)
        mc.select(loc, r=True)
    elif renderEngine == "arnold":
        assignArnoldShaders(chromnBall,grayBall,whiteBall)
        mc.select(loc, r=True)
    else:
        assignMayaShaders(chromnBall,grayBall,whiteBall)
        mc.select(loc, r=True)
Ejemplo n.º 28
0
def initializeBalloon(initRadius):
	mc.polySphere(sx = 12, sy = 8, n = "balloonTemp", r = initRadius)
	mc.rename( "polySphere1", "balloonTempHistory")
	mc.polySoftEdge( a = 180 )
	mc.lattice( n = 'balloon', cp = True, dv = (2, 4, 2), objectCentered = True,  ldv = (2, 3, 2), outsideLattice = True )
	mc.hide()
	mc.select('balloonTemp.vtx[84]', r=True)
	mc.ChamferVertex()
	mc.rename( "polyChamfer1", "tempChamfer" )
	mc.setAttr( 'tempChamfer.width', .1 )
	mc.delete( 'balloonTemp.f[72]' )
	return
Ejemplo n.º 29
0
def create_and_apply_materials(mdl_from_list):
    cmds.polySphere(sx=20, sy=30, r=0.5, name='sphere')
    mesh = cmds.ls(orderedSelection=True)

    mat = cmds.shadingNode(mdl_from_list,
                           name='test_%s' % mdl_from_list,
                           asShader=True)
    matSG = cmds.sets(name='%sSG' % mat,
                      empty=True,
                      renderable=True,
                      noSurfaceShader=True)
    cmds.connectAttr('%s.outColor' % mat, '%s.surfaceShader' % matSG)
    cmds.sets(mesh, e=True, forceElement=matSG)
Ejemplo n.º 30
0
    def setUp(self):
        ''' Called initially to set up the Maya test environment '''
        # Load plugins
        self.assertTrue(self.pluginsLoaded)

        # Open top_layer.ma scene in testSamples
        mayaUtils.openTopLayerScene()

        # Create some extra Maya nodes
        cmds.polySphere()

        # Clear selection to start off
        cmds.select(clear=True)
Ejemplo n.º 31
0
    def testSimplePrimWriter(self):
        mayaUsdLib.PrimWriter.Register(primWriterTest, "mesh")

        cmds.polySphere(r = 3.5, name='apple')

        usdFilePath = os.path.join(self.temp_dir,'testPrimWriterExport.usda')
        cmds.usdExport(mergeTransformAndShape=True,
            file=usdFilePath,
            shadingMode='none')

        self.assertTrue(primWriterTest.InitCalled)
        self.assertTrue(primWriterTest.WriteCalled)
        self.assertTrue(primWriterTest.PostExportCalled)
Ejemplo n.º 32
0
def testScene(prototype="shaderFX"):
    """
    Creates a boring default scene with a sphere
    Args:
        prototype (str): either with "shaderFX" or "prototypeC"
    """
    mnpr_system.check()
    # create and place test sphere
    cmds.polySphere()
    testSphere = cmds.ls(sl=True)
    mnpr_matPresets.createMaterial(testSphere, prototype=prototype)
    mnpr_matPresets.defaultLighting()
    lib.printInfo("Default scene created")
Ejemplo n.º 33
0
    def createCore(self):
        ''' This method creates the core for flower. '''

        mc.polySphere(ax=(0, 1, 0))
        self.currentCore = mc.ls(sl=True)
        mc.scale(1, 0.5, 1)
        mc.move(0, 0.2, 0)

        # delete history
        maya.mel.eval("DeleteHistory")

        mc.select(clear=True)

        return self.currentCore
Ejemplo n.º 34
0
def Fond(Stre, Freq, Ampl, colors={222, 202, 163}):
    cmds.file(f=True, new=True)

    # Stre=cmds.floatSliderGrp(field_strenth,q=True,v=True)
    # Freq=cmds.floatSliderGrp(field_frequency,q=True,v=True)
    # Ampl=cmds.floatSliderGrp(field_amplitude,q=True,v=True)

    #---------Creation Objet--------#
    cmds.polyCube(w=20, d=20, h=8, sx=80, sz=80, name="roche")  #20 20 / 50
    cmds.polySphere(r=10, sa=60, sy=60, name="contenant")  #8 / 12
    cmds.move(0, 6.5, 0, "contenant")
    cmds.polyBoolOp('contenant', 'roche', op=3, n='fond')
    cmds.delete(ch=True)
    cmds.move(0, -4, 0, "fond")

    #---------Selection Face--------#
    for i in range(0, 1707):
        cmds.select("fond.f[" + str(i) + "]", add=True)
        sl = cmds.ls(sl=True)

    #---------Texture Deformer--------#

    td = cmds.textureDeformer(s=Stre, ps="World", name="Textu".format(sl))
    n = cmds.shadingNode("noise".format(sl), asTexture=True)

    #--------Attributre Noise-------#
    cmds.setAttr("noise1.threshold", 0.014)
    cmds.setAttr("noise1.amplitude", Ampl)
    cmds.setAttr("noise1.ratio", 0.15)
    cmds.setAttr("noise1.frequency", Freq)
    cmds.setAttr("noise1.falloff", 1)

    cmds.connectAttr(n + ".outColor", td[0] + ".texture", force=True)

    Color = cmds.shadingNode('aiStandardSurface', name="colo", asShader=True)
    cmds.setAttr("colo.specular", 0)
    cmds.setAttr(Color + ".baseColor", colors[0], colors[1], colors[2])

    cmds.select("fond", hi=True, add=True)
    cmds.hyperShade(assign=Color)


#cmds.window()
#cmds.columnLayout()
#sliderStrenght=cmds.floatSliderGrp(field=True,label="Strenth",minValue=0,maxValue=3,value=1.5,w=400)
#sliderFreq=cmds.floatSliderGrp(field=True,label="Frequency",minValue=0,maxValue=1,value=0.3,w=400)
#sliderAmplitude=cmds.floatSliderGrp(field=True,label="Amplitude",minValue=0,maxValue=1,value=0.4,w=400)

#cmds.button(label="Fond", c="Fond()")
#cmds.showWindow()
Ejemplo n.º 35
0
 def createCore(self):
     ''' This method creates the core for flower. '''
     
     mc.polySphere( ax=(0, 1, 0) )
     self.currentCore = mc.ls( sl=True )
     mc.scale( 1, 0.5, 1 )
     mc.move( 0, 0.2, 0 )
     
     # delete history
     maya.mel.eval( "DeleteHistory" )
     
     mc.select( clear=True )
     
     return self.currentCore
def userSphere(*args):
    rs = cmds.intSliderGrp(radiussphere, q=True, v=True)
    #Move
    yms = cmds.intSliderGrp(ymovesphere, q=True, v=True)
    xms = cmds.intSliderGrp(xmovesphere, q=True, v=True)
    zms = cmds.intSliderGrp(zmovesphere, q=True, v=True)
    #Rotate
    yrs = cmds.intSliderGrp(yrotatesphere, q=True, v=True)
    xrs = cmds.intSliderGrp(xrotatesphere, q=True, v=True)
    zrs = cmds.intSliderGrp(zrotatesphere, q=True, v=True)
    #Application
    cmds.polySphere(r=rs)
    cmds.move(y=yms, x=xms, z=zms)
    cmds.rotate(y=yrs, x=xrs, z=zrs)
Ejemplo n.º 37
0
    def testExportJobContextConflicts(self):
        """Testing that merging incompatible contexts generates errors"""
        mark = Tf.Error.Mark()
        mark.SetMark()
        self.assertTrue(mark.IsClean())

        cmds.polySphere(r=1)
        usdFilePath = os.path.abspath('UsdExportSchemaApiTestBasic.usda')
        cmds.mayaUSDExport(mergeTransformAndShape=True,
                           file=usdFilePath,
                           jobContext=["Larry", "Curly", "Moe"])

        self.assertFalse(mark.IsClean())

        errors = mark.GetErrors()
        messages = set()
        for e in errors:
            messages.add(e.commentary)

        expected = set([
            "Arguments for job context 'Larry' can not include extra contexts.",
            "Context 'Curly' and context 'Larry' do not agree on type of argument 'apiSchema'.",
            "Context 'Moe' and context 'Larry' do not agree on argument 'geomSidedness'."
        ])
        self.assertEqual(messages, expected)

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

        mark = Tf.Error.Mark()
        mark.SetMark()
        self.assertTrue(mark.IsClean())

        cmds.polySphere(r=1)
        usdFilePath = os.path.abspath('UsdExportSchemaApiTestBasic.usda')
        cmds.mayaUSDExport(mergeTransformAndShape=True,
                           file=usdFilePath,
                           jobContext=["NullAPI", "Moe"])

        self.assertFalse(mark.IsClean())

        errors = mark.GetErrors()
        messages = set()
        for e in errors:
            messages.add(e.commentary)

        expected = set(
            ["Missing implementation for NullAPIChaser::ExportDefault"])
        self.assertEqual(messages, expected)

        cmds.file(f=True, new=True)
Ejemplo n.º 38
0
def createTargetPrim(*args):
    #delete existing target primitive
    #deleteTargetPrim()

    createTargetPrim.targetprim = 0

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

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

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

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

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

    if UI.targetPrim == 'Cone':
        mc.polyCone(sx=1, sy=1, sz=1)
        mc.hyperShade(assign=Materials.shader)
        #mc.polyColorPerVertex( rgb=(UI.targetR, UI.targetG, UI.targetB), cdo = True )
        if UI.targetMiddle != True:
            mc.move(random.randint(-10, 10), random.randint(-10, 10), 35)
Ejemplo n.º 39
0
def makeClouds():
    for i in range(0, 3):
        cmds.polySphere(r=20, sx=6, sy=6, n='cloud' + str(i))
        cmds.scale(1, 0.2, 0.5, 'cloud' + str(i))
        x = random.uniform(10, 100)
        y = random.uniform(60, 80)
        z = random.uniform(10, 100)
        cmds.move(i * x, y, z, 'cloud' + str(i))
        for j in range(0, 3):
            cmds.duplicate('cloud' + str(i), n='cloud' + str(i) + str(j))
            x = random.uniform(10, 100)
            y = random.uniform(60, 80)
            z = random.uniform(10, 100)
            cmds.move(i * x, y, j * z, 'cloud' + str(i) + str(j))
    cmds.refresh(f=True)
Ejemplo n.º 40
0
def QC_FunctionalTest2():
    # Resets everything
    QC_TestResetScene()
    QC_TestResetHypershade()
    # Creates two spheres
    cmds.polySphere(n='Object001')
    cmds.polySphere(n='Object002')
    # Moves the spheres
    cmds.move(0, 0, 0, 'Object001')
    cmds.move(2, 0, 0, 'Object002')
    # Selects the spheres
    cmds.select('Object001')
    cmds.select('Object002', add=True)
    # Runs the script
    QC_QuickChecker()
 def createCollisionSphereGuide(self, name):
     shpere = cmds.polySphere(name=n_collisionSphere, sx=6, sy=6)
     cmds.polyColorPerVertex(shpere[0],  rgb=(0.75,0.75,0))
     cmds.polyColorPerVertex(shpere[0], colorDisplayOption=1)
     self.setAttr(shpere[0],'overrideEnabled', 1)
     self.setAttr(shpere[0],'overrideDisplayType', 2)
     return shpere
Ejemplo n.º 42
0
def createLightStageLight(name, direction, diameterIn, distanceToFrontIn, useGroup=True):
    diameterCm = inchesToCentimeters(diameterIn)
    distanceToFrontCm = inchesToCentimeters(distanceToFrontIn)

    sphereLight = cmds.polySphere(name=name, r=0.5, sx=20, sy=20, ax=[0, 1, 0], cuv=2, ch=1)[0]
    lightScale = diameterCm
    cmds.setAttr("%s.%s" % (sphereLight, "scaleX"), lightScale)
    cmds.setAttr("%s.%s" % (sphereLight, "scaleY"), lightScale)
    cmds.setAttr("%s.%s" % (sphereLight, "scaleZ"), lightScale)

    if useGroup:
        cmds.setAttr("%s.%s" % (sphereLight, "scaleZ"), 0.0)

        lightGroup = cmds.group(sphereLight, name=("%sRotation" % sphereLight))

        lightTranslate = distanceToFrontCm
        cmds.setAttr("%s.%s" % (sphereLight, "translateZ"), lightTranslate)

        rx = -math.asin( direction[1] )*180.0/3.14159
        ry = math.atan2( direction[0], direction[2] )*180.0/3.14159

        cmds.setAttr("%s.%s" % (lightGroup, "rotateX"), rx)
        cmds.setAttr("%s.%s" % (lightGroup, "rotateY"), ry)

        return lightGroup
    else:
	    lightTranslate = map( lambda x: x*(distanceToFrontCm + diameterCm/2.), direction)
	    cmds.setAttr("%s.%s" % (sphereLight, "translateX"), lightTranslate[0])
	    cmds.setAttr("%s.%s" % (sphereLight, "translateY"), lightTranslate[1])
	    cmds.setAttr("%s.%s" % (sphereLight, "translateZ"), lightTranslate[2])

	    return sphereLight
Ejemplo n.º 43
0
def generateCollision(mode="sphere"):
    
    selected = cmds.ls(sl=True)
    
    if not selected:
        logging.error("Please Select Something")
        return
    
    xmin, ymin, zmin, xmax, ymax, zmax = cmds.xform(selected[0], q=True, bb=True) # give 6 values 
    
    width = abs(xmax - xmin)
    height = abs(ymax - ymin)
    depth = abs(zmax - zmin)
    
    name = selected[0] + "_COL" # new name
    
    if (mode == "box"):
        mesh = cmds.polyCube(w=width, h=height, d=depth, n=name)[0]
        
    if (mode == "sphere"):
        radius = max([width, height, depth])/2
        mesh = cmds.polySphere(r=radius, sx=10, sy=10,n=name)
        
    if (mode == "cylinder"):
        radius = max([width,depth])/2
        mesh = cmds.polyCylinder(r=radius, h=height, n=name, sc=1, sx=12, sy=1, sz=1)
    
    xPos = xmax - width/2
    yPos = ymax - height/2
    zPos = zmax - depth/2
    
    cmds.xform(mesh, ws=True, t=[xPos,yPos,zPos])
Ejemplo n.º 44
0
    def setUp(self):
        cmds.file(newFile=True, f=True)

        self.sphere = cmds.polySphere()
        self.loc1 = cmds.spaceLocator()[0]
        self.loc2 = cmds.spaceLocator()[0]
        self.joint = cmds.joint()
Ejemplo n.º 45
0
	def test_saveAs_export( self ):
		tmpdir = make_path( tempfile.gettempdir() ) / "maya_save_test"
		try:
			shutil.rmtree( tmpdir )	# cleanup
		except OSError:
			pass
		
		files = [ "mafile.ma" , "mb.mb", "ma.ma" ]
		for filename in files:
			mayafile = tmpdir / filename
			assert not mayafile.exists()
			Scene.save( mayafile , force=1 )
			assert mayafile.exists() 
		# END for each file to save
		
		# test remove unknown nodes
		assert Scene.name().ext() == ".ma"
		target_path = tmpdir / 'withoutunknown.mb'
		unode = cmds.createNode("unknown")
		
		# this doesnt work unless we have real unknown data - an unknown node 
		# itself is not enough
		# self.failUnlessRaises(RuntimeError, Scene.save, target_path)
		Scene.save(target_path, autodeleteUnknown=True)
		
		assert not cmds.objExists(unode)
		
		# must work for untitled files as well
		Scene.new( force = 1 )
		Scene.save( tmpdir / files[-1], force = 1 )

		
		# TEST EXPORT
		#############
		# as long as we have the test dir
		# export all 
		eafile = tmpdir / "export_all.ma"
		assert not eafile.exists()
		assert Scene.export(eafile) == eafile
		assert eafile.exists()
		
		# export selected
		nodes = cmds.polySphere()
		cmds.select(cl=1)				 # selects newly created ... 
		
		esfile = tmpdir / "export_selected.ma"
		assert not esfile.exists()
		
		assert not cmds.ls(sl=1)
		assert Scene.export(esfile, nodes) == esfile
		assert not cmds.ls(sl=1)			# selection unaltered
		
		assert esfile.isfile()
		
		# it truly exported our sphere
		Scene.new(force=1)
		esref = ref.createReference(esfile)
		assert len(list(esref.iterNodes(api.MFn.kMesh))) == 1
		
		shutil.rmtree( tmpdir )	# cleanup
Ejemplo n.º 46
0
        def createControl(lid, tz):
            locator1 = mc.spaceLocator(p = (0, 0, 0), n = '%s_locator%d' % (light, lid))[0]
            mc.parent(locator1, decay_grp)
            locator1 = "|%s|%s" % (decay_grp, locator1)
            mc.setAttr("%s.translateX" % locator1, lock = True)
            mc.setAttr("%s.translateY" % locator1, lock = True)
            mc.setAttr("%s.translateZ" % locator1, tz)

            sphere = mc.polySphere(r = 1, sx = 20, sy = 20, ax = (0, 1, 0), cuv = 0, ch = 0, n = '%s_sphere%d' % (light, lid))[0]
            mc.parent(sphere, decay_grp)
            sphere = "|%s|%s" % (decay_grp, sphere)
            
            # mc.pointConstraint(light, sphere, w = 1)
            mc.setAttr("%s.overrideEnabled" % sphere, 1)
            mc.setAttr("%s.overrideDisplayType" % sphere, 1)

            decomM1 = mc.createNode("decomposeMatrix")
            mc.connectAttr("%s.worldMatrix[0]" % light, "%s.inputMatrix" % decomM1, f = True)
            decomM2 = mc.createNode("decomposeMatrix")
            mc.connectAttr("%s.worldMatrix[0]" % locator1, "%s.inputMatrix" % decomM2, f = True)

            dis = mc.createNode("distanceBetween")
            mc.connectAttr("%s.outputTranslate" % decomM1, "%s.point1" % dis, f = True)
            mc.connectAttr("%s.outputTranslate" % decomM2, "%s.point2" % dis, f = True)
            mc.connectAttr("%s.distance" % dis, "%s.scaleX" % sphere, f = True)
            mc.connectAttr("%s.distance" % dis, "%s.scaleY" % sphere, f = True)
            mc.connectAttr("%s.distance" % dis, "%s.scaleZ" % sphere, f = True)

            return dis
Ejemplo n.º 47
0
def makeTree(shaders):
    '''
    Creates a tree.
    
    shaders: A list of shaders for the tree crown.
    On exit: A tree has been modeled, and is returned as a tuple 
             containing the object name and the node name. Some of the
             variables are chosen randomly to create different results.
    '''
    height = random.uniform(0.3,1.5)
    trunk = cmds.polyCylinder(name = "trunk", h = height, r = 0.07)
    cmds.sets(trunk[0], edit=True, forceElement="trunkMaterialGroup")
    cmds.xform(trunk, translation = (0,height/2.0 + 0.2,0))
    crown = cmds.polySphere(name = "crown", r = 0.5)
    cmds.xform(crown, translation = (0,height + 0.6,0))
    cmds.softSelect(sse = True, ssd = 0.86)
    cmds.select(crown[0] + ".vtx[381]")
    translation = random.uniform(0.3,1.5)
    cmds.move(translation, y = True, r = True)
    cmds.softSelect(sse = False)
    shader = random.choice(shaders)
    scale_ = random.uniform(0.7,1.8)
    cmds.select(crown)
    cmds.scale(scale_, scale_, scale_, pivot = (0,height,0))
    cmds.sets(crown[0], edit=True, forceElement= shader[1])
    tree = cmds.polyUnite(trunk[0],crown[0])
    cmds.delete(tree[0], ch = True)
    return tree
Ejemplo n.º 48
0
	def on3DSceneClick(self):
		if not cmds.window("autorigging_ui", exists=True) :
			self.resetExternalContext()
			return
		
		if not self.isActive :
			self.setConsoleText("Vous devez activer l'autorigging.",color=[255,0,0])
			return

		if not self.currentPointKey :
			self.setConsoleText("Choisissez un type de point a placer.")
			return


		pos = cmds.draggerContext("riggingContext", query=1, anchorPoint=1)
		strPos = "x:"+str(round(pos[0],2)) +"\ny:" + str(round(pos[1],2))

		if self.pointsMap[self.currentPointKey]["isSet"] is True :
			cmds.delete(self.currentPointKey+"sphere")
		
		
		nextObj = cmds.polySphere(name=self.currentPointKey+"sphere", radius=0.3)
		cmds.move(pos[0], pos[1], 10, nextObj)
		cmds.scale(1.0,1.0,0.0, nextObj)

		self.pointsMap[self.currentPointKey]["isSet"] = True
		self.pointsMap[self.currentPointKey]["clickedPoint"] = pos
		cmds.button(self.pointsMap[self.currentPointKey]["stateButton"], e=1, backgroundColor=[0,255,0],label=strPos)
Ejemplo n.º 49
0
def sphereCtl( name, functArgs ):
        J=[]
        ctl = Lib.getFirst(cmds.polySphere( n = (name + "_CTL"), r= functArgs["size"], sx= 1, sy= 1, ax= [0, 1, 0], ch= 1))
        grp = cmds.group( ctl, n = (name + "Ctl_GRP"))
        J.append(ctl)
        J.append(grp)
        return J
Ejemplo n.º 50
0
def test_create_constraint():
    _new()

    cube1, _ = map(cmdx.encode, cmds.polyCube())
    sphere1, _ = map(cmdx.encode, cmds.polySphere())

    cube1["translate"] = (1, 2, 0)
    sphere1["translate"] = (1, 4, 0)

    # Use commands, in case the interactive function is failing
    scene = commands.create_scene()
    commands.create_rigid(cube1, scene)
    commands.create_rigid(sphere1, scene)

    cmds.select(str(cube1), str(sphere1))
    opts = {"constraintSelect": False}
    assert_true(interactive.create_point_constraint(**opts))
    assert_true(interactive.create_orient_constraint(**opts))
    assert_true(interactive.create_parent_constraint(**opts))
    assert_true(interactive.create_hinge_constraint(**opts))
    assert_true(interactive.create_socket_constraint(**opts))

    assert_equals(len(cmds.ls(type="rdRigid")), 2)
    assert_equals(len(cmds.ls(type="rdScene")), 1)
    assert_equals(len(cmds.ls(type="rdConstraint")), 5)
Ejemplo n.º 51
0
 def setUp(self):
     cmds.file(newFile=True,f=True)
     
     self.sphere = cmds.polySphere()
     self.loc1 = cmds.spaceLocator()[0]
     self.loc2 = cmds.spaceLocator()[0]
     self.joint = cmds.joint()        
def tf_makeSphere(width, subdivs, parent, child, prefix, suffix ):       
    
    dummyBase = '%s' % (parent + child+ '_joint')
    dummyName = tf_dummyString(dummyBase, prefix, suffix)
    
    # create the cube
    
    createSphere = cmds.polySphere( r=width, ch=False, sx= 20, sy= 20, n= dummyName )
    
    
    cmds.editDisplayLayerMembers ( 'DummyLayer', createSphere)  
    
    # move cube to parent
    pointCon = cmds.pointConstraint( parent, createSphere[0] )
    
    # delete constraint once cube is in position
    cmds.delete( pointCon )
    
    # create the aim constraint
    #aimCon = cmds.aimConstraint( child, createSphere[0], aim=[0,0,1], u=[0,0,1] )
    
    # delete constraint once cube is aimed at child
    #cmds.delete( aimCon )
    
    #parent cube under the parent joint
    cmds.parent( createSphere[0], parent )
    
    # freeze transforms
    cmds.makeIdentity( createSphere[0], apply=True )
Ejemplo n.º 53
0
    def setUp(self):
        """Export some sphere geometry as .usda, and import into a new Maya scene."""

        cmds.file(force=True, new=True)
        cmds.loadPlugin("AL_USDMayaPlugin", quiet=True)
        self.assertTrue(
            cmds.pluginInfo("AL_USDMayaPlugin", query=True, loaded=True))

        with tempfile.NamedTemporaryFile(delete=False,
                                         suffix=".usda") as _tmpfile:
            self._usdaFile = _tmpfile.name
            # Ensure sphere geometry exists
            self._sphere = cmds.polySphere(constructionHistory=False,
                                           name="sphere")[0]
            cmds.select(self._sphere)

            # Export, new scene, import
            cmds.file(self._usdaFile,
                      exportSelected=True,
                      force=True,
                      type="AL usdmaya export")
            cmds.file(force=True, new=True)
            self._proxyName = cmds.AL_usdmaya_ProxyShapeImport(
                file=self._usdaFile)[0]

        # Ensure proxy exists
        self.assertIsNotNone(self._proxyName)

        # Store stage
        proxy = ProxyShape.getByName(self._proxyName)
        self._stage = proxy.getUsdStage()
Ejemplo n.º 54
0
def four():

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

    #base:
    base = cmds.polyCube(h=base_heigh, w=base_width, depth=base_depth)
    cmds.polyBevel3(base, offset=0.1)
    door = cmds.polyCube(h=base_heigh - base_heigh / 2,
                         w=base_width - base_width / 2,
                         depth=0.2)
    cmds.move(0, -base_heigh / 20.0, -base_width / 2.0)
    cmds.parent(base, door, oven)
    #swiches:
    sdoor = cmds.ls(door)
    for i in range(3):
        switch = cmds.polySphere(sx=5, sy=5, r=0.2)
        cmds.move(-base_width / 4.0 + i - 0.2 * i, base_heigh / 2.5,
                  -base_width / 2.1)
        cmds.parent(switch, oven)
    for i in range(2):
        heatersOne = cmds.polyCylinder(sx=7, sy=7, h=0.2, r=base_width / 1000)
        cmds.move(-base_width / 6.0 + i, base_heigh / 2.0, -base_width / 3.5)
        cmds.parent(heatersOne, oven)
    for i in range(2):
        heaterTwo = cmds.polyCylinder(sx=7, sy=7, h=0.2, r=base_width / 1000)
        cmds.move(-base_width / 6.0 + i, base_heigh / 2.0, base_width / 3.5)
        cmds.parent(heaterTwo, oven)
Ejemplo n.º 55
0
def creatSphere(*args):
    circleSel = mc.ls(sl=1)[0]
    radiusCircle = mc.circle(circleSel, q=1, r=1)
    radiusSpere = radiusCircle*.75
    particleSphere = mc.polySphere(n='%s_Sphere'%circleSel, r=radiusSpere, sx=float(radiusSpere), sy=float(radiusSpere), ax=[0, 1, 0])[0]
    mc.parentConstraint(circleSel, particleSphere, mo=0, w=1)
    #mc.parent(particleSphere, circleSel)
    mc.setAttr('%s.tx'%particleSphere, 0)
    mc.setAttr('%s.ty'%particleSphere, 0)
    mc.setAttr('%s.tz'%particleSphere, 0)
    mc.setAttr('%s.rx'%particleSphere, 0)
    mc.setAttr('%s.ry'%particleSphere, 0)
    mc.setAttr('%s.rz'%particleSphere, 0)
    mc.setAttr('%s.v'%particleSphere, 0)
    mc.select(particleSphere, r=1) 
    mc.emitter(type='surface', r=4, dx=1, dy=0, dz=0, n='%s_emitter'%circleSel )
    mc.particle( n='%s_Particles'%circleSel )
    mc.connectDynamic( '%s_Particles'%circleSel, em='%s_emitter'%circleSel )
    particlesShape = mc.listRelatives('%s_Particles'%circleSel, s=1)[0]
    mc.setAttr('%s.lifespanMode'%particlesShape, 1)
    mc.setAttr('%s.lifespan'%particlesShape, 0.4)
    mc.setAttr('%s.startFrame'%particlesShape, 1001)
    mc.connectControl( 'numText', '%s.rate'%('%s_emitter'%circleSel) )
    mc.shadingNode('blinn', n='%s_blinn'%circleSel, asShader=1)
    mc.sets( n='%s_blinnSG'%circleSel, renderable=True, noSurfaceShader=True, empty=1)
    mc.connectAttr('%s.outColor'%('%s_blinn'%circleSel), '%s.surfaceShader'%('%s_blinnSG'%circleSel))
    mc.connectControl( 'myColorIndex', '%s.color'%('%s_blinn'%circleSel) )
    mc.connectControl( 'lifeText', '%s.lifespan'%particlesShape )
    mc.sets('%s_Particles'%circleSel, e=1, forceElement='%s'%('%s_blinnSG'%circleSel))
Ejemplo n.º 56
0
def make_origin_target():
    o = cmds.polySphere() # create a sphere
    cmds.select(o) # select the sphere
    bbox = cmds.exactWorldBoundingBox() # create bounding box around it
    bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2] # define the bottom of the bounding box
    cmds.xform(piv=bottom, ws=True) # move the sphere to the bottom of the bounding box
    cmds.move(rpr=True)
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) # freeze transforms
Ejemplo n.º 57
0
def maya_test():
    import maya.standalone
    maya.standalone.initialize()
    from maya import cmds
    print 'sphere:', cmds.polySphere()
    cmds.file(rename="/home/mboers/key_tools/qbfutures/test.ma")
    cmds.file(force=True, save=True, type="mayaAscii")
    return 'DONE'
Ejemplo n.º 58
0
def createSphere(name, startJoint, endJoint):
    startHeight = mc.xform(startJoint, q=True, ws=True, t=True)
    endHeight = mc.xform(endJoint, q=True, ws=True, t=True)
    radius = (endHeight[1]-startHeight[1])/2
    tempSphere = mc.polySphere(n=name,r=radius)
    tempPos = (startHeight[0], startHeight[1]+radius, startHeight[2])
    mc.move(tempPos[0], tempPos[1], tempPos[2], r=True)
    return tempSphere[0]
Ejemplo n.º 59
0
def ballZ( inBitName ):
    bit = cmds.polySphere( axis=[0,0,1],
                             radius=4,
                             subdivisionsX=8,
                             subdivisionsY=4,
                             name=inBitName )
    # Return the name of the newly created bit.
    return bit[0]