本文整理汇总了Python中maya.cmds.polySphere函数的典型用法代码示例。如果您正苦于以下问题:Python polySphere函数的具体用法?Python polySphere怎么用?Python polySphere使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polySphere函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_shape
def make_shape(type, name, divisions):
"""
Creates shape based on argument passed
Args:
type: {cube, cone, cylinder, plane, torus, sphere}
name: name of the object
divisions: number of subdivisions we want to apply in x,y and z axis.
Same value will be taken in all axis.
Return:
None
"""
if type == 'cube':
mc.polyCube(n=name, sx=divisions, sy=divisions, sz=divisions)
elif type == 'cone':
mc.polyCone(n=name, sx=divisions, sy=divisions, sz=divisions)
elif type == 'cylinder':
mc.polyCylinder(n=name, sx=divisions, sy=divisions, sz=divisions)
elif type == 'plane':
mc.polyPlane(n=name, sx=divisions, sy=divisions)
elif type == 'torus':
mc.polyTorus(n=name, sx=divisions, sy=divisions)
elif type == 'sphere':
mc.polySphere(n=name, sx=divisions, sy=divisions)
else:
mc.polySphere()
示例2: test_assertConstrained
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
示例3: HI
def HI(self):
if self.checkSphere.isChecked():
cmds.polySphere()
if self.checkTorus.isChecked():
cmds.polyTorus()
if self.checkCube.isChecked():
cmds.polyCube()
pass
示例4: _setup_plugin
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)
示例5: snapToMeshTest
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])
示例6: createRig
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')
示例7: diamondLattice
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])
示例8: testBasicObjectSetMain
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
示例9: scBalls
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)
示例10: doIt
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')
示例11: RandomSphere
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))
示例12: lgtSpheresCreator
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)
示例13: createStaticSolarSystem
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")
示例14: initializeBalloon
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
示例15: createCore
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