本文整理汇总了Python中maya.cmds.polyCylinder函数的典型用法代码示例。如果您正苦于以下问题:Python polyCylinder函数的具体用法?Python polyCylinder怎么用?Python polyCylinder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polyCylinder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, name_, height, radius, sides, shader):
'''
Initializes a CylinderHouse object, and creates a polygonal house object based on a
cylinder primitive.
self: Object that is to be initialized.
name_: A string with the name the polygonal house object will have.
height: The height of the house.
radius: See Attributes.
sides: See Attributes.
shader: Shader that will be assigned to the house.
On exit: A CylinderHouse object has been initialized and a polygonal house has
been created out of a cylinder 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_, "cylinder", height, radius * 2, radius * 2)
self.radius = radius
self.sides = sides
n = cmds.polyCylinder(n = name_, r = radius, h = height, sx = sides, sy = height)
cmds.xform(n[0], translation = (0,height/2.0,0))
f = cmds.polyCylinder(n = "foundation", r = radius + 0.15, height = 0.8, sx = sides)
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: roundPlate
def roundPlate():
#get values from UI
rgb = cmds.colorSliderGrp('brickColour', query=True, rgbValue=True)
transparent = cmds.checkBox('makeTransparent', query = True, value = True)
base = cmds.polyCylinder( h = 0.18, r = 0.3 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18/2, moveY = True)
wide = cmds.polyCylinder( h = 0.14, r = 0.4 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18 + (0.14/2), moveY = True)
stud = cmds.polyCylinder( h = 0.18, r = 0.24 )
cmds.rotate( 90, rotateY = True )
cmds.move( 0.18 + 0.14 + (0.18/2), moveY = True)
rp = cmds.polyUnite( base, wide, stud )
myShader = cmds.shadingNode( 'phong', asShader=True )
cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3')
cmds.setAttr( myShader+".reflectivity", 0 )
if( transparent == True ):
cmds.setAttr( myShader+".transparency", 0.5, 0.5, 0.5, type = 'double3' )
cmds.select( rp )
cmds.hyperShade( assign = myShader )
cmds.delete( ch = True )
示例3: generate_kink_peice
def generate_kink_peice(cls, block_width):
components = []
boolean = []
for x in range(0, block_width + 1):
hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
boolean.append(hole[0])
cmds.rotate('90deg', 0, 0, hole[0])
cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0])
cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=Constants["block_height_unit"], depth=Constants["block_depth_unit"])
components.append(cube[0])
cmds.delete(cube[0] + ".f[40:47]")
cmds.move(half(block_width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)
#caps
cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap"))
cmds.rotate('90deg',0,0,cap_one[0])
cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0])
cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]")
components.append(cap_one[0])
#caps
cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"])
cmds.rotate('90deg','180deg',0,cap_two[0])
cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]")
cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0])
components.append(cap_two[0])
solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
cmds.polyMergeVertex( solid[0], d=0.15 )
cmds.delete(solid[0],ch=1)
return cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )
示例4: 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()
示例5: generate
def generate(cls, *args):
components = []
boolean = []
width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True)
rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True)
block_width = width * Constants["block_width_unit"]
block_height = Constants["block_height_unit"]
block_depth = Constants["block_depth_unit"]
for x in range(0, width):
stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"])
components.append(stub[0])
cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) + half(Constants["stub_height"]), half(Constants["block_depth_unit"]), stub[0])
for x in range(0, width-1):
hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2)
boolean.append(hole[0])
cmds.rotate('90deg', 0, 0, hole[0])
cmds.move(Constants["block_width_unit"] * x + Constants["block_width_unit"], 0, half(Constants["block_depth_unit"]), hole[0])
cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth)
components.append(cube[0])
cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube)
solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), ""))
boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean"))
final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )
shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat"))
cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3')
cmds.select(final[0], r=True)
cmds.hyperShade(assign=shader)
示例6: a_ring
def a_ring():
ring_diameter = 22 # outer diameter
ring_thickness = 1.5
divit_diameter = 1.5
divit_depth = .75
ring_height = 4
#divit_spacing = .5
divits = []
cmds.polyPipe(radius=ring_diameter/2, height=ring_height*2, thickness=ring_thickness, name='ring0')
cmds.setAttr( 'polyPipe1.subdivisionsAxis', 20 )
for x in range(0,6):
for y in range(0,3):
letter = initials[x]
symbol = letter[y]
myName = "_c" + str(x) + str(y)
if symbol == 0 :
cmds.polyCylinder(axis=[0,0,1], radius=(divit_diameter/2), height=divit_depth, name=myName)
elif symbol == 2:
cmds.polyCylinder(axis=[0,0,1], radius=(divit_diameter/2), height=ring_thickness * 2.1, name=myName)
if symbol != 1:
divits.append(myName)
y_off = 0
cmds.move(0,y_off,(ring_diameter/2 - divit_depth/2 + .3),myName)
cmds.rotate(0,(x*3+y)*20,0,myName, pivot=[0,0,0])
rn = 0;
for d in divits[:]:
print 'ring' + str(rn) + " " + d
cmds.polyBoolOp('ring' + str(rn), d, op=2, n='ring' + str(rn+1), )
rn += 1
示例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: RandomCylinder
def RandomCylinder():
cmds.polyCylinder(h = random.randrange(1,50), r = random.randrange(1,50), sx=4, sy=4, sz=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))
示例9: makeRingList
def makeRingList(num):
rings=[]
cmds.polyCylinder(n="ring", h=0.2, r=0.5)
cmds.move(-8,0.1,0, 'ring', a=True)
cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
for i in range(0,num):
v = cmds.duplicate("ring")
rings.append(v[0])
cmds.delete('ring')
return rings
示例10: newScene
def newScene():
cmds.polyPlane(n="floor", h=30, w=30, sx=1, sy=1)
cmds.polyCylinder(n="src", h=5, r=0.2)
cmds.move(0,2.5,0, 'src', a = True)
cmds.duplicate("src", n="temp")
cmds.duplicate("src", n="dest")
cmds.move(-8,0,0, "src", r=True)
cmds.move(8,0,0, "dest", r=True)
assignNewMaterial('floorMaterial', [0.3, 0.2, 0], 'floor')
assignNewMaterial('pegMaterial', [0,0,0], 'src')
assignMaterial('pegMaterial', 'temp')
assignMaterial('pegMaterial', 'dest')
示例11: makeTree
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
示例12: crystalise
def crystalise(base):
'''
Adds hexagonal crystals to a branch
base : The branch to be crystallised
A crystal is created by scaling the top and bottom rings of vertices of a
cylinder. The crystal is aligned to the base branch and scaled to match.
The crystal is duplicated, randomly distributed along the branch and scaled
relative to their positioning. The crystals are combined with the base branch
mesh and this object is returned.
'''
crystal=[cmds.polyCylinder(r=1,sx=6,sy=2)[0]]
cmds.polySoftEdge(crystal[0], a=0)
cmds.scale(0.6,0.3,0.6,crystal[0]+'.f[12:13]',r=1)
[(tx,ty,tz)] = cmds.getAttr(base+'.translate')
[(rx,ry,rz)] = cmds.getAttr(base+'.rotate')
cmds.move(tx,ty,tz,crystal[0])
cmds.rotate(rx,ry,rz,crystal[0])
[x1,y1,z1,x2,y2,z2] = cmds.xform(base+'.vtx[0:1]',q=1,t=1,ws=1)
baseScale = cmds.getAttr(base+'.scaleX')
cmds.scale(0.5,0.2,0.5,crystal[0])
length = ((x2-x1)**2+(z2-z1)**2)**0.5
for i in range(0,6):
crystal[len(crystal):]=[cmds.duplicate(crystal[0])[0]]
for x in crystal:
dist = (random.random())
cmds.move(length*dist,0,0,x,os=1,r=1,wd=1)
size = (1.5-dist)*(length/3)
cmds.scale(size,size,size,x,r=1)
cmds.rotate(0,30,0,x,r=1)
crystal += [base]
return combineParts(crystal,base)
示例13: createABranch
def createABranch(rotAxis, angle):
global prevRot,prevPos
'''Extract Euler angles from constructed quaternion'''
euAngles=EulerAnglesFromAxisQuat(rotAxis, angle)
#print toDegrees(euAngles[0])#x
#print toDegrees(euAngles[1])#y
#print toDegrees(euAngles[2])#z
'''Create Cylinder'''
if firsttime == True:
firsttime=False
branch = mc.polyCylinder(n='cy1', r=0.1, height=branchLength)#axis=(dirx[0],diry[0],dirz[0]),
prevCylinder=branch
else:
topPrevCylinderV1= cmds.xform(prevCylinder[0]+'.vtx[24]', translation=True, query=True)
topPrevCylinderV2= cmds.xform(prevCylinder[0]+'.vtx[34]', translation=True, query=True)
topfaceMidleX=(topPrevCylinderV1[0]+topPrevCylinderV2[0]) /2
topfaceMidleY=(topPrevCylinderV1[1]+topPrevCylinderV2[1]) /2
topfaceMidleZ=(topPrevCylinderV1[2]+topPrevCylinderV2[2]) /2
mycurve=cmds.curve( p=[(topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX, topfaceMidleY, topfaceMidleZ), (topfaceMidleX+1, topfaceMidleY+1, topfaceMidleZ+1)] )
cmds.select(prevCylinder[0]+'.f[21]')
cmds.select(mycurve, add=True)
cmds.polyExtrudeFacet(constructionHistory=1, keepFacesTogether=1, pvx= -1.11758709e-08, pvy=0.5, pvz= -1.490116119e-08, divisions=10 ,twist=0, taper=1, off=0, thickness=0, smoothingAngle=30, inputCurve=mycurve)
开发者ID:yanioaioan,项目名称:LSystem_UsingQuaternions-AutoMatedGeneration,代码行数:25,代码来源:LSystem_UsingQuaternions-AutoMatedGenerationExtend.py
示例14: generateCollision
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])
示例15: createRoundedBlock
def createRoundedBlock( blockSizeX, blockSizeY, blockSizeZ, blockLength ):
edgeCylinderL = cmds.polyCylinder ( h = blockSizeZ, r = blockSizeY/2 )
cmds.rotate( 90, rotateX = True )
cmds.move( ( -blockSizeX/2 ), moveX = True, a=True)
edgeCylinderR = cmds.polyCylinder ( h = blockSizeZ, r = blockSizeY/2 )
cmds.rotate( 90, rotateX = True )
cmds.move( ( blockSizeX/2 ), moveX = True, a=True)
block = cmds.polyCube ( h = blockSizeY, w = blockSizeX, d = blockSizeZ, sx = ( blockLength - 1 ) * 2, sy = 2 )
block = cmds.polyCBoolOp( block, edgeCylinderL, op = 1 )
block = cmds.polyCBoolOp( block, edgeCylinderR, op = 1 )
return block