本文整理汇总了Python中maya.cmds.polyCube函数的典型用法代码示例。如果您正苦于以下问题:Python polyCube函数的具体用法?Python polyCube怎么用?Python polyCube使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polyCube函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, name_, height, width, depth, shader):
'''
Initializes a BoxHouse object, and creates a polygonal house object based on a
box primitive.
self: Object that is to be initialized.
name_: name_: A string with the name the polygonal house object will have.
height: The height of the house.
width: The width of the house.
depth: The depth of the house.
shader: Shader that will be assigned to the house.
On exit: A BoxHouse object has been initialized and a polygonal house has
been created out of a box primitive. A foundation for the house has
also been created and united with the box. The given shader has been
assigned to the house.
'''
House.__init__(self, name_, "box", height, width, depth)
n = cmds.polyCube(n = "house_", w = width, h = height, d = depth, sy = height)
cmds.xform(n[0], translation = (0, height/2.0, 0))
f = cmds.polyCube(n = "foundation", w = width + 0.3, h = 0.8, d = depth + 0.3)
cmds.xform(f[0], translation = (0,0.4,0))
n = cmds.polyUnite(n[0],f[0], n = name_)
self.name = n[0]
cmds.sets(n[0], edit=True, forceElement= shader[1])
cmds.delete(self.name, ch = True)
示例2: updateData
def updateData(self, useRootOffsetData=False):
if useRootOffsetData:
#Take out offset
useZ = cmds.checkBox(g_rootOffsetZBox, q=True, value=True)
useY = cmds.checkBox(g_rootOffsetYBox, q=True, value=True)
rootPosition = cmds.xform('Root', q=True, t=True)
boxPosition = cmds.xform( self.m_name, q=True, t=True)
#zero X because we don't care
boxPosition[0] = 0
if useZ and useY:
#Both Axis offset
boxPosition[1] = boxPosition[1] - rootPosition[1]
boxPosition[2] = boxPosition[2] - rootPosition[2]
elif useZ and not useY:
boxPosition[2] = boxPosition[2] - rootPosition[2]
elif not useZ and useY:
boxPosition[1] = boxPosition[1] - boxPosition[1]
self.m_position = boxPosition
self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2]))
self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True )
self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2)
self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2)
else:
self.m_position = cmds.xform( self.m_name, q=True, t=True ) #Finds the translation, we should probably be finding the point of hte bottom left corner??
self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2]))
self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True )
self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2)
self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2)
示例3: testPolyUVs
def testPolyUVs(self):
MayaCmds.polyCube(name = 'cube')
cubeObj = getObjFromName('cubeShape')
fnMesh = OpenMaya.MFnMesh(cubeObj)
# get the name of the current UV set
uvSetName = fnMesh.currentUVSetName()
uArray = OpenMaya.MFloatArray()
vArray = OpenMaya.MFloatArray()
fnMesh.getUVs(uArray, vArray, uvSetName)
newUArray = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, -1, -1]
newVArray = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 1 , 0, 1]
for i in range(0, 14):
uArray[i] = newUArray[i]
vArray[i] = newVArray[i]
fnMesh.setUVs(uArray, vArray, uvSetName)
self.__files.append(util.expandFileName('polyUvsTest.abc'))
MayaCmds.AbcExport(j='-uv -root cube -file ' + self.__files[-1])
# reading test
MayaCmds.AbcImport(self.__files[-1], mode='open')
MayaCmds.select('cube.map[0:13]', replace=True)
uvs = MayaCmds.polyEditUV(query=True)
for i in range(0, 14):
self.failUnlessAlmostEqual(newUArray[i], uvs[2*i], 4,
'map[%d].u is not the same' % i)
self.failUnlessAlmostEqual(newVArray[i], uvs[2*i+1], 4,
'map[%d].v is not the same' % i)
示例4: createCube
def createCube(self, *args):
i = 0
j = 0
k = 1
posX = 0
cubeStock = []
dupCubeStock = []
self.cubeNumX = self.numX_input()
self.cubeNumZ = self.numZ_input()
while i < self.cubeNumX :
cmds.polyCube( w = 10, h = 10, d = 10, sx = self.divX_input(), sy = self.divY_input(), sz = self.divZ_input(), ax = (0, 1, 0), cuv = 4, ch = 1)
cmds.move(15 * i, 0, 0)
self.cubeName = str(cmds.pickWalk(d = "up"))
self.splittedCubeName = self.cubeName.split("'")[1]
self.cubeFinalName = unicode(self.splittedCubeName)
print("cubeFinalName : " + self.cubeFinalName)
cubeStock.append(self.cubeFinalName)
i += 1
while j < self.cubeNumZ :
posX = cmds.getAttr(str(cubeStock[j]) + ".translateX")
cmds.select(cubeStock[j], r = True)
dup = cmds.duplicate(cubeStock[j])
cmds.move(posX, 0, 15 * k)
j += 1
k += 1
示例5: testAnimMeshReload
def testAnimMeshReload(self):
MayaCmds.polyCube( name = 'mesh')
MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[1, 24])
MayaCmds.setKeyframe('meshShape.vtx[0:7]')
MayaCmds.currentTime(12, update=True)
MayaCmds.select('meshShape.vtx[0:7]')
MayaCmds.scale(5, 5, 5, r=True)
MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[12])
self.__files.append(util.expandFileName('testAnimMeshReadWrite.abc'))
MayaCmds.AbcExport(j='-fr 1 24 -root mesh -f ' + self.__files[-1])
# reading test
MayaCmds.AbcImport(self.__files[-1], mode='open')
# save as a maya file
self.__files.append(util.expandFileName('test.mb'))
MayaCmds.file(rename=self.__files[-1])
MayaCmds.file(save=True)
# reload as a maya file
MayaCmds.file(self.__files[-1], open=True)
MayaCmds.AbcImport(self.__files[-2], mode='import')
retVal = True
mesh1 = '|mesh|meshShape'
mesh2 = '|mesh1|meshShape'
for t in range(1, 25):
MayaCmds.currentTime(t, update=True)
if not util.compareMesh( mesh1, mesh2 ):
self.fail('%s and %s were not equal at frame %d' % (mesh1,
mesh2, t))
示例6: makeRobot
def makeRobot():
MayaCmds.polyCube(name="head")
MayaCmds.move(0, 4, 0, r=1)
MayaCmds.polyCube(name="chest")
MayaCmds.scale(2, 2.5, 1)
MayaCmds.move(0, 2, 0, r=1)
MayaCmds.polyCube(name="leftArm")
MayaCmds.move(0, 3, 0, r=1)
MayaCmds.scale(2, 0.5, 1, r=1)
MayaCmds.duplicate(name="rightArm")
MayaCmds.select("leftArm")
MayaCmds.move(1.25, 0, 0, r=1)
MayaCmds.rotate(0, 0, 32, r=1, os=1)
MayaCmds.select("rightArm")
MayaCmds.move(-1.25, 0, 0, r=1)
MayaCmds.rotate(0, 0, -32, r=1, os=1)
MayaCmds.select("rightArm", "leftArm", "chest", r=1)
MayaCmds.group(name="body")
MayaCmds.polyCube(name="bottom")
MayaCmds.scale(2, 0.5, 1)
MayaCmds.move(0, 0.5, 0, r=1)
MayaCmds.polyCube(name="leftLeg")
MayaCmds.scale(0.65, 2.8, 1, r=1)
MayaCmds.move(-0.5, -1, 0, r=1)
MayaCmds.duplicate(name="rightLeg")
MayaCmds.move(1, 0, 0, r=1)
MayaCmds.select("rightLeg", "leftLeg", "bottom", r=1)
MayaCmds.group(name="lower")
MayaCmds.select("head", "body", "lower", r=1)
MayaCmds.group(name="robot")
示例7: testExportToDiskLayer
def testExportToDiskLayer(self):
"""
Tests that exporting to an on-disk layer that is open elsewhere in the
process still works.
"""
cmds.file(new=True, force=True)
cmds.polyCube(name='TestCube')
filePath = os.path.abspath("testStage.usda")
stage = Usd.Stage.CreateNew(filePath)
stage.Save()
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.usdExport(
file=filePath,
mergeTransformAndShape=True,
shadingMode='none')
self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.rename('TestCube', 'TestThing')
cmds.usdExport(
file=filePath,
mergeTransformAndShape=True,
shadingMode='none')
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
示例8: testExportToAnonymousLayer
def testExportToAnonymousLayer(self):
"""
Tests exporting to an existing anonymous layer. In normal (non-append)
mode, this should completely overwrite the contents of the anonymous
layer.
"""
cmds.file(new=True, force=True)
cmds.polyCube(name='TestCube')
stage = Usd.Stage.CreateInMemory()
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.rename('TestCube', 'TestThing')
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())
示例9: placeBlock
def placeBlock(self, *args) :
cmds.polyCube(w=1,h=1)
name=cmds.ls(sl=True)
w=cmds.floatFieldGrp('dim',query=True, value1=True)
h=cmds.floatFieldGrp('dim',query=True, value2=True)
cmds.setAttr('%s.scaleX' %(name[0]),w/2.0)
cmds.setAttr('%s.scaleY' %(name[0]),h/2.0)
r=cmds.floatFieldGrp('rotation',query=True, value1=True)
cmds.addAttr(name[0],ln='BodyType', dt='string')
bt=cmds.optionMenuGrp("bodyType", query=True ,value=True)
cmds.setAttr('%s.BodyType' %(name[0]),bt ,type='string')
cmds.addAttr(name[0],ln='friction')
f=cmds.floatFieldGrp('friction',query=True, value1=True)
cmds.setAttr('%s.friction' %(name[0]),f)
cmds.addAttr(name[0],ln='restitution')
r=cmds.floatFieldGrp('restitution',query=True, value1=True)
cmds.setAttr('%s.restitution' %(name[0]),r)
cmds.addAttr(name[0],ln='density')
d=cmds.floatFieldGrp('density',query=True, value1=True)
cmds.setAttr('%s.density' %(name[0]),d)
r=cmds.floatFieldGrp('rotation',query=True, value1=True)
cmds.setAttr('%s.rotateZ' %(name[0]),r)
示例10: birth
def birth(self, mom):
x=2
cmds.polyCube(n=self.name, w=0, h=0, d=0)
cmds.scale(self.size-x,self.size-x,self.size-x, absolute = True)
p=cmds.pointConstraint(mom, self.name)
cmds.delete(p)
cmds.parent(self.name, mom)
示例11: 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()
示例12: testExportWithClashStripping
def testExportWithClashStripping(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(add="foo")
cmds.namespace(set="foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
errorRegexp = "Multiple dag nodes map to the same prim path" \
".+|cube1 - |foo:cube1.*"
with self.assertRaisesRegexp(RuntimeError, errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
with self.assertRaisesRegexp(RuntimeError,errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=False,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
示例13: testExportWithStripAndMerge
def testExportWithStripAndMerge(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
cmds.namespace(add=":foo")
cmds.namespace(add=":bar")
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube2" )
cmds.namespace(set=":bar");
node3 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube3" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
expectedPrims = ("/cube1", "/cube2", "/cube3")
for primPath in expectedPrims:
prim = stage.GetPrimAtPath(primPath)
self.assertTrue(prim.IsValid(), "Expect " + primPath)
示例14: test_agst
def test_agst(self):
# animated geometry, static transform node
nodename = 'agst_node'
MayaCmds.polyCube(name=nodename)
MayaCmds.select(nodename+'.vtx[0:8]')
MayaCmds.setKeyframe(time=1.0)
MayaCmds.scale(1.5, 1.5, 1.8)
MayaCmds.setKeyframe(time=5.0)
self.__files.append(util.expandFileName('agst_motionblur_noSampleGeo_Test.abc'))
MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -wfg -root %s -file %s' % (
nodename, self.__files[-1]))
# frameRange: 1, 2, 3, 4, 5, 6
self.isFrameRangeTransAndFrameRangeShapeExists(self.__files[-1])
self.__files.append(util.expandFileName('agst_motionblur_Test.abc'))
MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -root %s -f %s' % (
nodename, self.__files[-1]))
# frameRange: 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6
self.isFrameRangeExists(self.__files[-1])
self.__files.append(util.expandFileName('agst_noSampleGeo_Test.abc'))
MayaCmds.AbcExport(j='-fr 1 5 -wfg -root %s -f %s' % (nodename,
self.__files[-1]))
# frameRange: 1, 2, 3, 4, 5
self.isFrameRangeExists(self.__files[-1])
示例15: makeStreetTree
def makeStreetTree(shaders):
'''
Creates a tree on a circular platform and with a circular fence around it.
shaders: A list of shaders for the tree crowns.
On exit: A tree has been created using makeTree(...), a circular platform
has been created underneath it and a fence around it. Appropriate
shaders have been assigned. Everything is united into one polygonal
object and returned as a tuple with the object name and the node
name.
'''
tree = makeTree(shaders)
platform = cmds.polyCylinder(name = "platform",h = 0.1, r = 0.8)
cmds.move(0.25, y = True)
cmds.sets(platform[0], edit=True, forceElement="fountainMaterialGroup")
pole = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04)
cmds.xform(pole, t = (0.7,0.45,0))
angle = 360/10.0
for i in range(1,10):
pole1 = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04)
cmds.rotate(angle * i, y = True)
cmds.move(0.7,0.45,0, os = True)
pole = cmds.polyUnite(pole, pole1)
bar = cmds.polyPipe(name = "bar", h = 0.1, r = 0.65, t = 0.04)
cmds.move(0.65, y = True)
bar1 = cmds.duplicate(bar[0])
cmds.move(-0.2, y = True, r = True)
fence = cmds.polyUnite(pole, bar, bar1)
cmds.sets(fence[0], edit=True, forceElement="blackMetalGroup")
streetTree = cmds.polyUnite(tree,platform, fence)
cmds.delete(streetTree, ch = True)
return streetTree