• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cmds.polyEvaluate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中maya.cmds.polyEvaluate函数的典型用法代码示例。如果您正苦于以下问题:Python polyEvaluate函数的具体用法?Python polyEvaluate怎么用?Python polyEvaluate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了polyEvaluate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getFaces

def getFaces():
    # count faces
    faceCount = cmds.polyEvaluate(geometryName[0],f=True)
    # make a list of face count
    faceRange = list(range(1,faceCount))

    # empty list for face
    faceList = []

    # for each face in faceRange, get the name of the face
    for f in faceRange:
        # get the name of each face on the model
        face = (str(geometryName[0])+'.f['+str(f)+']')

        # append each face to the faceList
        faceList.append(face)

    faceCount = cmds.polyEvaluate(geometryName[0],f=True)

    # empty list for facebounds
    fb = []

    # if the faceList is equal to the number of faces found    
    if len(faceList) == faceCount-1:
        # for each face name found in face list
        for face in faceList:
            # select each face
            cmds.select(face)
            # get the UV bounding box on each face
            faceBounds = cmds.polyEvaluate(bc2=True)
            # print the facebounds
            fb.append(faceBounds)

    if len(fb) == len(faceList):
        return fb,faceList
开发者ID:njculpin,项目名称:maya_scripts,代码行数:35,代码来源:select_face_color_from_texture.py


示例2: MeshDict

def MeshDict(mesh = None, pointCounts = True, calledFrom = None):
    """
    Validates a mesh and returns a dict of data.
    If a shape is the calling object, it will be the shape returned, otherwise, the first shape in the chain will be

    :param mesh: mesh to evaluate
    
    :returns:
    dict -- mesh,meshType,shapes,shape,pointCount,pointCountPerShape
    

    """        
    _str_funcName = 'MeshDict'
    if calledFrom: _str_funcName = "{0} calling {1}".format(calledFrom,_str_funcName) 
    
    _mesh = None 
    
    if mesh is None:
        _bfr = mc.ls(sl=True)
        if not _bfr:raise ValueError,"No selection found and no source arg"
        mesh = _bfr[0]
        log.info("{0}>> No source specified, found: '{1}'".format(_str_funcName,mesh))
           
    _type = search.returnObjectType(mesh)
    _shape = None
    _callObjType = None
    
    if _type in ['mesh']:
        _mesh = mesh
        _callObjType = 'meshCall'
    elif _type in ['shape']:
        _shape = mesh
        _callObjType = 'shapeCall'
        _mesh = getTransform(mesh)
    else:
        raise ValueError,"{0} error. Not a usable mesh type : obj: '{1}' | type: {2}".format(_str_funcName, mesh, _type)

    _shapes = mc.listRelatives(_mesh,shapes=True,fullPath=False)
    
    if _shape is None:
        _shape = _shapes[0]
        
    _return = {'mesh':_mesh,
               'meshType':_type,
               'shapes':_shapes,
               'shape':_shape,
               'callType':_callObjType,
               }
    
    if pointCounts:
        if _callObjType == 'shapeCall':
            _return['pointCount'] = mc.polyEvaluate(_shape, vertex=True)
        else:
            _l_counts = []
            for s in _return['shapes']:
                _l_counts.append( mc.polyEvaluate(s, vertex=True))
            _return['pointCountPerShape'] = _l_counts
            _return['pointCount'] = sum(_l_counts)

    return _return   
开发者ID:Italic-,项目名称:maya-prefs,代码行数:60,代码来源:validateArgs.py


示例3: returnObjectSize

def returnObjectSize(obj,debugReport = False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Semi intelligent object sizer. Currently works for verts, edges,
    faces, poly meshes, nurbs surfaces, nurbs curve

    ARGUMENTS:
    obj(string) - mesh or mesh group

    RETURNS:
    size(float)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    objType = search.returnObjectType(obj)

    #>>> Poly
    if objType == 'mesh':
        size =  mc.polyEvaluate(obj,worldArea = True)

        if debugReport: print ('%s%f' %('mesh area is ',size))
	return size

    elif objType == 'polyVertex':
        meshArea = mc.polyEvaluate(obj,worldArea = True)
        splitBuffer = obj.split('.')
        vertices = mc.ls ([splitBuffer[0]+'.vtx[*]'],flatten=True)
        size = meshArea/len(vertices)

        if debugReport: print ('%s%f' %('Average mesh area per vert is  ',size))
        return size

    elif objType == 'polyEdge':
        size = returnEdgeLength(obj)

        if debugReport: print ('%s%f' %('The Edge length is ',size))
        return size

    elif objType == 'polyFace':
        size =  returnFaceArea(obj)

        if debugReport: print ('%s%f' %('face area is ',size))
        return size

    #>>> Nurbs
    elif objType == 'nurbsSurface':
        boundingBoxSize = returnBoundingBoxSize(obj)
        size = cgmMath.multiplyList(boundingBoxSize)

        if debugReport: print ('%s%f' %('Bounding box volume is ',size))
        return size

    elif objType == 'nurbsCurve':
        size =  returnCurveLength(obj)

        if debugReport: print ('%s%f' %('Curve length is ',size))
        return size
    else:
        if debugReport: print ("Don't know how to handle that one")
        return False
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:60,代码来源:distance.py


示例4: copyWeights

def copyWeights(sourceMesh, targetMesh, sourceDeformer, targetDeformer):
    """
	Copy deformer weights from one mesh to another.
	Source and Target mesh objects must have matching point order!
	@param sourceMesh: Mesh to copy weights from
	@type sourceMesh: str
	@param targetMesh: Mesh to copy weights to
	@type targetMesh: str
	@param sourceDeformer: Deformer to query weights from
	@type sourceDeformer: str
	@param targetDeformer: Deformer to apply weights to
	@type targetDeformer: str
	"""
    # Check source and target mesh
    if not mc.objExists(sourceMesh):
        raise Exception('Source mesh "' + sourceMesh + '" does not exist!!')
    if not mc.objExists(targetMesh):
        raise Exception('Target mesh "' + targetMesh + '" does not exist!!')

        # Check deformers
    if not mc.objExists(sourceDeformer):
        raise Exception('Source deformer "' + sourceDeformer + '" does not exist!!')
    if targetDeformer and not mc.objExists(targetDeformer):
        raise Exception('Target deformer "' + targetDeformer + '" does not exist!!')
    if not targetDeformer:
        targetDeformer = sourceDeformer

    # Compare vertex count
    if mc.polyEvaluate(sourceMesh, v=True) != mc.polyEvaluate(targetMesh, v=True):
        raise Exception("Source and Target mesh vertex counts do not match!!")

        # Copy weights
    wtList = glTools.utils.deformer.getWeights(sourceDeformer, sourceMesh)
    # Paste weights
    glTools.utils.deformer.setWeights(targetDeformer, wtList, targetMesh)
开发者ID:auqeyjf,项目名称:glTools,代码行数:35,代码来源:mirrorDeformerWeights.py


示例5: triangulateMesh

def triangulateMesh(isObj, simplify, smoothe):
	if isObj and not cmds.objExists('triObj'):
		cmds.select(baseObject)
		cmds.duplicate(baseObject, name = "triObj")
		cmds.select('triObj')

		if smoothe:
			cmds.polySmooth('triObj', c=smoothe)
			cmds.polyReduce(ver = 1)
			cmds.polyReduce(ver = 1)

		if simplify > 0:
			cmds.polyReduce(ver = 1, p = simplify)

		num_faces = cmds.polyEvaluate('triObj', f=True)
		
		print "Triangulating faces..."
		#iterate over faces
		face_i = 0
		while face_i < num_faces:
			if ((num_faces - face_i) % 5 == 0):
				print "Triangulate check: Approximately " + str(num_faces - face_i) + " faces remaining...."
			face = cmds.select('triObj.f['+ str(face_i)+']')		
			verts = getCorners(isObj,face_i)
			if not isCoplanar(verts):
				cmds.polyTriangulate('triObj.f['+ str(face_i)+']')
				num_faces = cmds.polyEvaluate('triObj', f=True)
			face_i +=1
开发者ID:ahamburger,项目名称:bedazzler,代码行数:28,代码来源:bedazzle.py


示例6: get_invalid

    def get_invalid(cls, instance):
        invalid = []

        for node in cmds.ls(instance, type='mesh'):
            uv = cmds.polyEvaluate(node, uv=True)

            if uv == 0:
                invalid.append(node)
                continue

            vertex = cmds.polyEvaluate(node, vertex=True)
            if uv < vertex:

                # Workaround:
                # Maya can have instanced UVs in a single mesh, for example
                # imported from an Alembic. With instanced UVs the UV count from
                # `maya.cmds.polyEvaluate(uv=True)` will only result in the unique
                # UV count instead of for all vertices.
                #
                # Note: Maya can save instanced UVs to `mayaAscii` but cannot
                #       load this as instanced. So saving, opening and saving
                #       again will lose this information.
                uv_to_vertex = cmds.polyListComponentConversion(node + ".map[*]",
                                                                toVertex=True)
                uv_vertex_count = len_flattened(uv_to_vertex)
                if uv_vertex_count < vertex:
                    invalid.append(node)
                else:
                    cls.log.warning("Node has instanced UV points: {0}".format(node))

        return invalid
开发者ID:BigRoy,项目名称:pyblish-magenta,代码行数:31,代码来源:validate_mesh_has_uv.py


示例7: hfSplitBadShaded

    def hfSplitBadShaded(self, engines):
        modifiedShapes = []
        for sg in engines:
            print('checking shading group: '+sg)
            cmds.hyperShade(objects=sg)
            components = cmds.ls(sl=1)
            uniqueShapes = []
            for entry in components:
                uniqueShapes.append(entry.split('.')[0])
                # remove whole shapes (not components) from the list.
                if entry.rfind('.f') == -1:
                    components.remove(entry)
            if len(components) > 0:
                components.sort()
                # remove duplicates from uniqueShapes.
                uniqueShapes = list(set(uniqueShapes))
                modifiedShapes.extend(uniqueShapes)
                # print('\nunique shapes under shading group: ')
                # print(uniqueShapes)
                for shape in uniqueShapes:
                    cmds.select(cl=1)
                    # get the total num of faces for the shape for later use.
                    totalFaces = cmds.polyEvaluate(shape, f=1)
                    for comp in components:
                        testStr = shape+'.f['
                        if testStr in comp:
                            # the current component is a member of the current mesh we're splitting and it has the shader we want.
                            cmds.select(comp, add=1)
                    selFaces = cmds.ls(sl=1)
                    # print 'selection:'
                    # print selFaces
                    # extract the selected faces if we aren't selecting every face of the current mesh.
                    if len(selFaces) < int(totalFaces) and len(selFaces) > 0:
                        cmds.polyChipOff(selFaces, kft=1, dup=0)
                        cmds.delete(shape,ch=1)
                    # now the mesh is broken into shells. separate it if possible.
                    if cmds.polyEvaluate(shape, s=1) > 1:
                        newObjects = cmds.polySeparate(shape, ch=0)
                        modifiedShapes.extend(newObjects)
                        # print('split new shapes: ')
                        # print(newObjects)
                        cmds.select(newObjects)
                        # print(cmds.ls(sl=1))
                        cmds.delete(ch=1)
        cmds.select(cl=1)
        # now in order to return all the new meshes we made, we should sort through uniqueShapes and remove anything that no longer
        # exists. anything that's been split, etc.
        modifiedShapes = list(set(modifiedShapes))
        returnShapes = []
        for shape in modifiedShapes:
            if cmds.objExists(shape) == 0:
                modifiedShapes.remove(shape)
            else:
                meshNodes = cmds.listRelatives(shape, s=1)
                if meshNodes != None:
                # if we are not testing an xform, meshNodes will be a 'NoneType' object so we should include an exception.
                    returnShapes.extend(meshNodes)

        return returnShapes
开发者ID:mkolar,项目名称:pyblish-bumpybox,代码行数:59,代码来源:validate_component_shading.py


示例8: ftb_gen_shell_doIt

def ftb_gen_shell_doIt(dist,distUV,div):
	if (mc.window('shellUiWin',q=True,exists=True)):
		mc.deleteUI('shellUiWin')
	#mc.loadPlugin( 'c:/ftb_mayaplugins/ppl/2011 x64/shellNode.mll')
	sel = mc.ls(sl=True)
	if(len(sel)!= 0):
		shape = mc.listRelatives(sel[0],noIntermediate = True,shapes=True)
		His = mc.listHistory(shape[0])
		shell = ''
		for h in His:
			if(mc.nodeType(h) == 'polyShell'):
				shell = h
		if(shell == ''):
			if(mc.attributeQuery('shThickness',node=shape[0],ex=True)):
				dist = mc.getAttr(shape[0]+'.shThickness')
			else:
				mc.addAttr(shape[0],ln="shThickness",at='double',dv=0)
				mc.setAttr(shape[0]+'.shThickness',e=True,keyable=True)
			if(mc.attributeQuery('shUvThickness',node=shape[0],ex=True)):
				distUV = mc.getAttr(shape[0]+'.shUvThickness')
			else:
				mc.addAttr(shape[0],ln="shUvThickness",at='double',dv=0)
				mc.setAttr(shape[0]+'.shUvThickness',e=True,keyable=True)
			if(mc.attributeQuery('shDiv',node=shape[0],ex=True)):
				div = mc.getAttr(shape[0]+'.shDiv')
			else:
				mc.addAttr(shape[0],ln="shDiv",at='long',dv=0,min=0)
				mc.setAttr(shape[0]+'.shDiv',e=True,keyable=True)
			faceInitalCount = mc.polyEvaluate(sel[0],f=True)
			mc.polyShell(thickness = dist,uvOffset = distUV);
			sel2 = mc.ls(sl=True)
			faceFinalCount = mc.polyEvaluate(sel[0],f=True)
			mc.addAttr(sel2[0],ln="div",at='long',min=0,dv=0)
			mc.setAttr(sel2[0]+'.div',e=True,keyable=True)
			mc.setAttr(sel2[0]+'.div',div)
			mc.addAttr(sel2[0],ln="splits",dt="string")
			mc.setAttr(sel2[0]+'.splits',e=True,keyable=True)
			mc.select((sel[0]+'.f[%i' % (faceInitalCount*2)+':%i' % faceFinalCount+']'))
			faceList = mc.ls(sl=True,fl=True)
			facesRings = makeFaceRingGroups(faceList)
			for faceRing in facesRings:
				mc.select(facesRings[faceRing])
				mc.ConvertSelectionToContainedEdges()
				mc.setAttr(sel2[0]+'.thickness',0.2)
				split = mc.polySplitRing(mc.ls(sl=True),ch=True,splitType=2,divisions=0,useEqualMultiplier=1,smoothingAngle=30,fixQuads=1)
				splits = mc.getAttr(sel2[0]+'.splits')
				if(splits == None):
					splits = ""
				mc.setAttr(sel2[0]+'.splits',("%s"%splits+"%s,"%split[0]),type="string")
				mc.connectAttr(sel2[0]+'.div', (split[0]+'.divisions'))
				mc.setAttr(sel2[0]+'.thickness',dist)
				
			mc.connectAttr(sel2[0]+'.thickness',shape[0]+'.shThickness')
			mc.connectAttr(sel2[0]+'.uvOffset',shape[0]+'.shUvThickness')
			mc.connectAttr(sel2[0]+'.div',shape[0]+'.shDiv')
		else:
			print('This mesh have a shellModifier allready!!!!!')
	else:
		mc.error("please select some mesh")
开发者ID:skarone,项目名称:PipeL,代码行数:59,代码来源:polyShell.py


示例9: setObjectAsCanvas

def setObjectAsCanvas(name):
	cmds.polyEvaluate(f=True)
	subdivSurface = cmds.polyToSubdiv(maxPolyCount=cmds.polyEvaluate(f=True), maxEdgesPerVert=32, ch=False)[0]
	liveSurface = cmds.subdToNurbs(subdivSurface, ot=0, ch=False)
	cmds.delete(subdivSurface)
	cmds.hide(liveSurface)
	cmds.makeLive(liveSurface)

	return liveSurface
开发者ID:TomMinor,项目名称:mesh-surface-spawner,代码行数:9,代码来源:PaintGUI.py


示例10: cutCell

def cutCell(obj, mat, pos, rot, shardsGRP):
	#do the cut procedure
	tocut = mc.polyEvaluate(obj, face = True)
	mc.polyCut( ('%s.f[0:%d]'% (obj,tocut)), pc = (pos[0], pos[1], pos[2]), ro = (rot[0], rot[1], rot[2]), ch = False, df = True)
	cutFaces = mc.polyEvaluate(obj, face = True)
	mc.polyCloseBorder(obj, ch = False)
	newFaces = mc.polyEvaluate(obj, face = True)
	newFaces = newFaces - cutFaces
	#assign material to faces
	for face in range(newFaces):
		mc.sets( ( '%s.f[ %d ]' % (obj, (cutFaces + newFaces - 1))), forceElement = ('%sSG' % (mat)),  e = True)
开发者ID:pinkwerks,项目名称:Maya-Scripts,代码行数:11,代码来源:dg_voroPy.py


示例11: initMeshFromMayaMesh

	def initMeshFromMayaMesh(self, meshName):
		_vs = []
		_faces = []
		numV = mc.polyEvaluate(meshName, v=True)
		numF = mc.polyEvaluate(meshName, f=True)
		for i in range(numV):
			_vs.append(mc.pointPosition(meshName+".vtx["+str(i)+"]"))
		for i in range(numF):
			_faces.append(self.faceVtxList(meshName+".f["+str(i)+"]"))
		self.vs = _vs
		self.faces = _faces
开发者ID:songjaewon,项目名称:autoRig,代码行数:11,代码来源:trimesh.py


示例12: rec

def rec(object_name, volume_total, cut_planes, volume_ratios, threshold, result, loop_num):
	# base cases
	if loop_num == 0:
		print 'insert more coins to continue'
		return False
	elif mc.polyEvaluate(object_name, shell = True) > 1:
		# more than one shell in object named 'object_name'
		print 'NO REDEMPTION'
		return False
	elif len(volume_ratios) == 1:
		# check ratio matches
		this_ratio = mm.eval('meshVolume(\"' + object_name + '\")') / volume_total
		# since its last one, might have more errors
		if abs(this_ratio - volume_ratios[0]) < threshold * 4:
			# duplicate the object
			temp = mc.duplicate(object_name)
			mc.select(temp[0], r = True)
			# move away the duplication
			mc.move(kMoveAwayXDistance, 0, 0, temp[0])
			# remove the current object
			mc.delete(object_name)
			print 'DONE with last object!'
			result.append(temp[0])
			print result
			return True
		else:
			print 'last object did NOT match last ratio!', this_ratio, volume_ratios[0]
			return False

	# recursive step
	random.shuffle(cut_planes)
	result_from_cutting = cut_object_with_planes_and_ratios(object_name, volume_total, cut_planes, volume_ratios, threshold)
	if isinstance(result_from_cutting, list):
		# this list contains all successfully cut objects and we are done
		result.extend(result_from_cutting)
		print 'lucky!'
		print result
		return True
	else:
		print 'Enter recursive step'
		# dictionary returned
		# extend result list with what we have now
		result.extend(result_from_cutting['good_cut_objs'])
		# merge the remaining objects into one
		bad_cut_objs = result_from_cutting['bad_cut_objs']
		if mc.polyEvaluate(bad_cut_objs, shell = True) > 1:
			united_objects = mc.polyUnite(bad_cut_objs)[0]
			mc.polyMergeVertex(united_objects)
		else:
			united_objects = bad_cut_objs[0]
		# get list of ratios un-resolved
		ratios_remaining = result_from_cutting['ratios_remaining']
		recursion_result = rec(united_objects, volume_total, cut_planes, ratios_remaining, threshold, result, loop_num-1)
		return recursion_result
开发者ID:a0077952,项目名称:fyp_transformers,代码行数:54,代码来源:testcut1.py


示例13: create

	def create(self):
		"""create hairsystem for lock"""
		numFace = mc.polyEvaluate( self.mesh.shape.name, f = True )
		numVert = mc.polyEvaluate( self.mesh.shape.name, v = True )
		if not self.hairSystem:
			print 'There is no hairSystem assigned to this HairLock --> init with one or assign one.... '
		if not numFace % 2 or not numVert == ( numFace + 3 ):
			print 'This mesh dosen\'t have odd number of faces', self.mesh.name, 'SKYPING'
			return
		self._curveMesh = mn.createNode('curvesFromMesh' )
		self._curveMesh.name = self.mesh.name + '_curveMesh'
		self.mesh.shape.a.outMesh     >> self._curveMesh.a.inMesh
		self.mesh.shape.a.worldMatrix >> self._curveMesh.a.inWorldMatrix
		for i in range(5):	
			hairCurve = mn.createNode('nurbsCurve' )
			hairCurveParent = hairCurve.parent
			hairCurveParent.name = self.mesh.name + '_%i'%i + '_crv'
			hairCurve = hairCurveParent.shape
			self._curveMesh.attr( 'outCurve[%i'%i + ']' ) >> hairCurve.a.create
			
			follicle = mn.createNode('follicle')
			folliclePar = follicle.parent
			folliclePar.name = self.mesh.name + '_%i'%i + '_foll'
			follicle = folliclePar.shape
			hairSustemOutHairSize = self.hairSystem.a.outputHair.size 
			follicle.a.outHair >> self.hairSystem.attr( 'inputHair[%i'%hairSustemOutHairSize + ']' )
			#follicle.a.outHair >> self.hairSystem.attr( 'inputHair[%i'%i + ']' )
			hairCurve.a.worldSpace >> follicle.a.startPosition
			self.hairSystem.attr( 'outputHair[%i'%hairSustemOutHairSize + ']' ) >> follicle.a.currentPosition
			self._follicles.append(follicle)
			self._curves.append(hairCurve)
			#if there is a scalp mesh use that for the position of the follicle
			if self.scalp:
				self.scalp.shape.a.outMesh >> follicle.a.inputMesh
				self.scalp.a.worldMatrix   >> follicle.a.inputWorldMatrix
				u,v = self._getUVCoordFromScalpForFollicle( hairCurve )
				follicle.a.parameterV.v       = v
				follicle.a.parameterU.v       = u
				#hairCurveParent.parent        = folliclePar
			else:
				self.mesh.shape.a.outMesh  >> follicle.a.inputMesh
				self.mesh.a.worldMatrix    >> follicle.a.inputWorldMatrix
				follicle.a.parameterV.v       = 0.5
				follicle.a.parameterU.v       = 0.5
			follicle.a.overrideDynamics.v = 0
			follicle.a.startDirection.v   = 1
			follicle.a.clumpWidthMult.v   = 1.5
			follicle.a.densityMult.v      = 0.5
			follicle.a.sampleDensity.v    = 1.5
			follicle.a.outTranslate >> follicle.parent.a.translate
			follicle.a.outRotate >> follicle.parent.a.rotate
开发者ID:skarone,项目名称:PipeL,代码行数:51,代码来源:hair.py


示例14: flipWeights

def flipWeights(sourceDeformer,targetDeformer,sourceInfluence,targetInfluence,axis='x'):
	'''
	'''
	# Check dnBurlyDeformer
	if not glTools.utils.dnBurlyDeformer.isBurlyDeformer(sourceDeformer):
		raise Exception('A valid source dnBurlyDeformer must be provided!')
	
	if not isBurlyDeformer(targetDeformer):
		raise Exception('A valid target dnBurlyDeformer must be provided!')
	
	# Get influence indices
	sourceInfluenceIndex = glTools.utils.dnBurlyDeformer.getInfluenceIndex(sourceDeformer,sourceInfluence)
	targetInfluenceIndex = glTools.utils.dnBurlyDeformer.getInfluenceIndex(targetDeformer,targetInfluence)
	
	# Get affected geometry
	sourceGeo = glTools.utils.deformer.getAffectedGeometry(sourceDeformer).keys()[0]
	targetGeo = glTools.utils.deformer.getAffectedGeometry(targetDeformer).keys()[0]
	sourceGeoPntNum = mc.polyEvaluate(sourceGeo,v=True)
	targetGeoPntNum = mc.polyEvaluate(targetGeo,v=True)
	
	# Get source influence weights
	sourceInfluenceWeights = glTools.utils.dnBurlyDeformer.getInfluenceWeights(dnBurlyDeformer,sourceInfluence)
	
	# Get affected geometry
	targetInfluenceWeights = [0.0 for i in range(targetGeoPntNum)]
	
	# Build vertex correspondence table
	vtxTable = []
	for i in range(sourceGeoPntNum):
		# Get source vertex position
		pos = glTools.utils.base.getPosition(sourceGeo+'.vtx['+str(i)+']')
		
		# Get mirror position
		mPos = pos
		mPos[axisInd] *= -1.0
		
		# Get closest vertex to mirror position
		mVtx = glTools.utils.mesh.closestVertex(targetGeo,mPos)
		vtxTable.append(mVtx)
		
	# Build target influence weights
	for i in range(len(sourceInfluenceWeights)):
		targetInfluenceWeights[vtxTable[i]] = sourceInfluenceWeights[i]
	
	# Set influence weights
	glTools.utils.dnBurlyDeformer.setInfluenceWeights(targetDeformer,targetInfluence,targetInfluenceWeights)
	
	# Rebind influence
	mm.eval('dnBurlyDeformer -rebindMuscle "'+targetDeformer+'" "'+targetInfluence+'"')
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:49,代码来源:dnBurlyDeformer.py


示例15: isComponent

def isComponent(shape):
    result = None
    cmds.select(shape)
    vert = cmds.polyEvaluate(vertexComponent=True)
    face = cmds.polyEvaluate(faceComponent=True)
    edge = cmds.polyEvaluate(edgeComponent=True)
    if vert > 0:
        result = "vert"
    elif face > 0:
        result = "face"
    elif edge > 0:
        result = "edge"
    else:
        result = False
    return result
开发者ID:jdynamite,项目名称:autorigger,代码行数:15,代码来源:follicle.py


示例16: modify_surface

def modify_surface():
    
    perlin = True
    sel = mc.ls(selection=True,long=True)
    for verts in sel:
        totalVerts = mc.polyEvaluate(verts, vertex=True)
        for number in xrange(totalVerts):
            if perlin == True:
				frequency = 1.0
				amplitude = 1.5
				octaves = 8
				for o in xrange(octaves):
				    randX = random.triangular(-0.2 , 0.0, 0.2)
				    posX = perlinNoise(randX ,0,0)
				    
				    randY = random.triangular(-0.4 , 0.0, 0.6)
				    posY = perlinNoise(0,randY,0)
				    
				    randZ = random.triangular(-0.2 , 0.0, 0.2)
				    posZ = perlinNoise(0,0,randZ)
				    
				    posX *= frequency
				    posY *= frequency
				    posZ *= frequency 
				    
				    mc.select(verts+'.vtx[{number}]'.format(number=number))
				    mc.move(posX,posY*amplitude,posZ,relative=True)
				    mc.rotate(posY*amplitude,y=True)
    mc.select(sel, replace=True)
    mc.makeIdentity(s=True, a=True, t=True,r=True)
开发者ID:PaulElmo,项目名称:Landscape_Generator,代码行数:30,代码来源:TerrainGen.py


示例17: buildSymTable

def buildSymTable(mesh):
    symDict = {}
    posDict = {}
    negDict = {}
    
    # store positions in separate positive and negative dictionaries
    vtxCount = mc.polyEvaluate(mesh, v=1)
    for vtxvertId in range(vtxCount):
        posX, posY, posZ = mc.xform('%s.vtx[%d]'%(mesh,vtxvertId), q=1, t=1, os=1)
        if posX > 0:
            posDict[(posX,posY,posZ)] = vtxvertId
        elif posX < 0:
            negDict[(posX,posY,posZ)] = vtxvertId
    
    # match positive to negative verts in symmetry table
    for posKey, vtxvertId in posDict.items():
        negKey = (-posKey[0], posKey[1], posKey[2])
        if negKey in negDict:
            symDict[vtxvertId] = negDict[negKey]
    
    # select assymetrical verts
    asymVerts = ['%s.vtx[%d]'%(mesh, vertId) for vertId in range(vtxCount) if vertId not in symDict.keys() and vertId not in symDict.values()]
    mc.select(asymVerts)

    return symDict
开发者ID:sayehaye3d,项目名称:ls-rigging-tools,代码行数:25,代码来源:symmetry.py


示例18: on_loadUpVert_pushButton_released

    def on_loadUpVert_pushButton_released(self):

        sel = cmds.ls(selection=True,flatten=True)

        if len(sel) > 0:

            shape = cmds.ls(selection=True, objectsOnly=True)[0]

            if cmds.nodeType(shape) == 'mesh':
                if cmds.polyEvaluate()['vertexComponent']>0:

                    verts = []
                    for vert in sel:

                        verts.append(vert)

                    self.upVert = verts
                    self.upVert_label.setText('Vert loaded!')
                    self.loadUpVert_pushButton.setStyleSheet(self.loadedStyleSheet)
                else:
                    cmds.warning('No vert selected!')
            else:
                cmds.warning('Selection is not a vertex!')
        else:
            cmds.warning('Nothing is selected!')
开发者ID:mkolar,项目名称:Tapp,代码行数:25,代码来源:gui.py


示例19: exportWeight

def exportWeight (objs, path) :
    xmlFile = open(path,'w')
    root_node = xml.Element('exportedSkinWeight')
        
    for obj in objs:
        skinCluster = getSkinClusterNode(obj)
        vertexCount = cmds.polyEvaluate(obj, v=True)
        jointDicts = getJointDicts(skinCluster)
        
        obj_node = xml.Element('objectName')
        obj_node.text = obj
        root_node.append(obj_node)

        # PROGRESS BAR START
        gMainProgressBar = mel.eval('$tmp = $gMainProgressBar')
        cmds.progressBar( gMainProgressBar, edit=True, beginProgress=True, status="PROCESS // Exporting Weight : %s (count = %d)" %(obj,vertexCount), maxValue=vertexCount)
            
        for vertex in range(vertexCount):
            for jointDict in jointDicts:
                value = cmds.getAttr(skinCluster+'.wl[%d].w[%d]' %(int(vertex), int(jointDict['jointIndex'])))
                if not value == 0:
                    vtx_node = xml.Element('skinWeightInfo')
                    obj_node.append(vtx_node)
                    vtx_node.attrib['vertex'] = str(vertex)
                    vtx_node.attrib['jointName'] = jointDict['jointName']
                    vtx_node.attrib['value'] = str(value)
            #PROGRESS BAR STEP
            cmds.progressBar(gMainProgressBar, edit=True, step=1)
            
        # PROGESS BAR END
        cmds.progressBar(gMainProgressBar, edit=True, endProgress=True)
        
    indent(root_node)
    xml.ElementTree(root_node).write(xmlFile)
    xmlFile.close()
开发者ID:adamfok,项目名称:afok_toolset,代码行数:35,代码来源:skin_weight_editor.py


示例20: ShapeInverterCmdold

def ShapeInverterCmdold(base=None, corrective=None, name=None):
    mc.undoInfo(openChunk=True)
    if not base or not corrective:
        sel = mc.ls(sl=True)
        base, corrective = sel
    shapes = mc.listRelatives(base, children=True, shapes=True)
    for s in shapes:
        if mc.getAttr("%s.intermediateObject" % s) and mc.listConnections("%s.worldMesh" % s, source=False):
            origMesh = s
            break
    deformed = mc.polyPlane(ch=False)[0]
    mc.connectAttr("%s.worldMesh" % origMesh, "%s.inMesh" % deformed)
    mc.setAttr("%s.intermediateObject" % origMesh, 0)
    mc.delete(deformed, ch=True)
    mc.setAttr("%s.intermediateObject" % origMesh, 1)
    if not name:
        name = "%s_inverted#" % corrective
    invertedShape = duplicateMesh(base, name=name)
    deformer = mc.deformer(invertedShape, type="ShapeInverter")[0]
    mc.ShapeInverterCmd(baseMesh=base, invertedShape=invertedShape, ShapeInverterdeformer=deformer, origMesh=deformed)
    # correctiveShape = duplicateMesh(base,name=corrective+"_corrective#")
    # mc.connectAttr('%s.outMesh' % getShape(correctiveShape), '%s.correctiveMesh' % deformer)
    # transferMesh(corrective,[correctiveShape])
    mc.connectAttr("%s.outMesh" % getShape(corrective), "%s.correctiveMesh" % deformer)
    mc.setAttr("%s.activate" % deformer, True)
    mc.delete(deformed)
    bdingBx = mc.polyEvaluate(corrective, boundingBox=True)
    xDifVal = bdingBx[0][1] - bdingBx[0][0]
    # mc.move(xDifVal*1.10,correctiveShape,r=True,moveX=True)
    mc.move(xDifVal * 2.20, invertedShape, r=True, moveX=True)
    mc.undoInfo(closeChunk=True)
    return invertedShape  # ,correctiveShape
开发者ID:jonntd,项目名称:cvShapeInverter,代码行数:32,代码来源:ShapeInverterScript.py



注:本文中的maya.cmds.polyEvaluate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cmds.polyListComponentConversion函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.polyEditUV函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap