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

Python cmds.error函数代码示例

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

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



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

示例1: exportObj

def exportObj():
    try:
        fileName = cmds.textField(objNameInput, q=True, tx=True).split(".")[0] + ".obj"
        cmds.file(os.path.split(furnitureFilePath)[0] + "/meshes/furniture/" + fileName, pr=1, typ="OBJexport", es=1, op="groups=0; ptgroups=0; materials=0; smoothing=0; normals=1")
        logging.info("Obj Save Success")
    except:
        cmds.error("Could not save OBJ - Make sure the plugin is loaded")
开发者ID:SweetheartSquad,项目名称:Scripts,代码行数:7,代码来源:FurnitureComponentScript.py


示例2: bt_moveObjToCamera

def bt_moveObjToCamera():
    
    #Check for hotkey and make if possible
    bt_checkCtrFHotkey()

    activePanel = cmds.getPanel(wf=1)
    if "model" in activePanel:
        activeCamera = cmds.modelEditor(activePanel,q=1,camera=1)   
    else:
        cmds.error ('No active panel/camera to frame to')    
         
    selected = cmds.ls(sl=1)
    
    locator = cmds.spaceLocator()
    cmds.select(activeCamera,add=1)
    cmds.parent(r=1)
    cmds.move(0,0,-5,locator,r=1,os=1)
    location = cmds.xform(q=1,t=1,ws=1)
    
    for object in selected:
        cmds.move(location[0],location[1],location[2],object,ws=1,a=1)
        #cmds.move(location[0],location[1],location[2],'pCube1',ws=1,a=1)
        
    cmds.delete(locator)   
    cmds.select(selected,r=1)
开发者ID:cyrillef,项目名称:apps.exchange.packager,代码行数:25,代码来源:bt_moveObjToCamera.py


示例3: createLocators

    def createLocators(self):
        #create list of loc names (self.name)
        for i in range(len(self.jointList)):
            self.locList.append("%s_%s_Loc"%(self.jointList[i],self.limbName))

        #check that these don't exist already
        if (cmds.objExists(self.locList[0])):
            cmds.error("these limb locators exists already!")
        else:

            #fill dictionary - assign values from list
            self.locPos = {}
            for j in range(len(self.locList)):
                self.locPos[self.locList[j]] = self.locPosValues[j]

            #create the locs
            for key in self.locPos.keys():
                thisLoc = cmds.spaceLocator(n=key)
                cmds.move(self.locPos[key][0], self.locPos[key][1], self.locPos[key][2], thisLoc)

            #parent them together (from list of loc names)
            for k in range((len(self.locList)-1),0,-1):
                cmds.parent(self.locList[k], self.locList[k-1])

######### make this true only for the arms. . . or figure out how to extract which rot this should be
            #rotate second joint to just get a preferred angle
            cmds.setAttr("%s.ry"%self.locList[1], -5)
开发者ID:zethwillie,项目名称:python_rigger,代码行数:27,代码来源:baseLimb.py


示例4: sendall

	def sendall(self, filePath= None, longMsg= None, postFunc= None, *args, **kwargs):
		""" Send file as string split by half of buffer size due to encoding
		besause @postFunc is using [funcSend] to send a function after package,
		it's execute result will override the result of the func in package.
		"""
		# a global var as buffer: mTeleport_buffer
		msg = "global mTeleport_buffer; mTeleport_buffer= ''"
		self.cmdSend(msg, True)
		# image to string
		if filePath is not None:
			package = open(filePath, 'r')
		else:
			package = StringIO(longMsg)
		# sending
		try:
			success = False
			fixBuff = max(4, self.buff / 2)
			msg = "global mTeleport_buffer\n" \
				+ "mTeleport_buffer += '%s'.decode('base64')\n"
			while True:
				pString= package.read(fixBuff)
				if not pString:
					break
				# encode segment
				pak = msg % base64.b64encode(pString)
				self.cmdSend(pak, True)
			success = True
		except:
			cmds.error('Failed to send all.')
		package.close()
		# post function
		if postFunc and success:
			result = self.funcSend(postFunc, *args, **kwargs)
			return result
		return None
开发者ID:davidpower,项目名称:MS_AniRemap,代码行数:35,代码来源:pointA.py


示例5: loadPlugin

def loadPlugin():
    """
    load softSelectionQuery plugin
    """
    
    mayaVers = int(mayaVersion())
    os = cmds.about(os=1)
    
    if os == 'win64':
        pluginName = 'softSelectionQuery_%s-x64.mll' % mayaVers
    elif os == 'mac':
        pluginName = 'softSelectionQuery_%s.bundle' % mayaVers
    elif os == 'linux64':
        pluginName = 'softSelectionQuery_%s.so' % mayaVers
    else:
        cmds.error('Soft Cluster EX is available for 64bit version of Autodesk Maya 2011 '
                  'or above under Windows 64bit, Mac OS X and Linux 64bit!')
    
    if not cmds.pluginInfo(pluginName, q=True, l=True ):
        cmds.loadPlugin(pluginName)
        version = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s loaded success!' % (pluginName, version))
    else:
        version = cmds.pluginInfo(pluginName, q=1, v=1)
        log.info('Plug-in: %s v%s has been loaded!' % (pluginName, version))
开发者ID:griffinanimator,项目名称:ThirdParty,代码行数:25,代码来源:setup.py


示例6: setCorneaBulge

def setCorneaBulge(*args):
    print args
    if len(gEyeballCtrler) == 0:
        cmds.error('Please set current eyeball controler.')
    else:
        gCorneaBulgeValue = args[0]
        cmds.setAttr(gEyeballCtrler + '.corneaBulge', gCorneaBulgeValue)
开发者ID:raina-wu,项目名称:maya_plugin_diy,代码行数:7,代码来源:eyeball.py


示例7: doIt

    def doIt(self, argList):
        # get only the first object from argument list
        try:
            obj = misc.getArgObj(self.syntax(), argList)[0]
        except:
            cmds.warning("No object selected!")
            return
        if (cmds.objectType(obj) != 'transform'):
            cmds.error("Object is not of type transform!")
            return

        # get and cast array of MPoint-Objects to list structure (needed for ConvexHull)
        pSet = list([p.x, p.y, p.z] for p in misc.getPoints(obj))
        # execute convex hull algorithm on point set of current object
        hull = ConvexHull(pSet)
        # get empty mesh object
        mesh = om2.MFnMesh()
        # add each polygon (triangle) in incremental process to mesh
        center = cmds.centerPoint(obj)
        for i,tri in enumerate(hull.points[hull.simplices]):
            # triangle vertices are not ordered --> make sure all normals point away from object's center
            v1 = map(operator.sub, tri[0], tri[1])
            v2 = map(operator.sub, tri[0], tri[2])
            # cross product of v1 and v2 is the current face normal; if dot product with vector from origin is > 0 use vertex order 0,1,2 and if dot product < 0 reverse order (all triangles are defined clockwise when looking in normal direction -- counter-clockwise when looking onto front of face)
            if (np.dot(np.cross(v1, v2), map(operator.sub, tri[0], center) ) > 0 ):
                mesh.addPolygon( ( om2.MPoint(tri[0]), om2.MPoint(tri[1]), om2.MPoint(tri[2]) ) )
            else:
                mesh.addPolygon( ( om2.MPoint(tri[0]), om2.MPoint(tri[2]), om2.MPoint(tri[1]) ) )
        # get transform node of shapeNode and rename it to match object's name
        transformNode = cmds.listRelatives(mesh.name(), p = 1)
        transformNode = cmds.rename(transformNode, obj + "_ch")
        self.setResult(transformNode)
开发者ID:EnReich,项目名称:ProKlaue,代码行数:32,代码来源:convexHull.py


示例8: checkMaxSkinInfluences

 def checkMaxSkinInfluences(self, node, maxInf, debug=1, select=0):
     '''Takes node name string and max influences int.
     From CG talk thread (MEL converted to Python, then added some things)'''
     
     cmds.select(cl=1)
     skinClust = self.findRelatedSkinCluster(node)
     if skinClust == "": cmds.error("checkSkinInfluences: can't find skinCluster connected to '" + node + "'.\n");
 
     verts = cmds.polyEvaluate(node, v=1)
     returnVerts = []
     for i in range(0,int(verts)):
         inf= cmds.skinPercent(skinClust, (node + ".vtx[" + str(i) + "]"), q=1, v=1)
         activeInf = []
         for j in range(0,len(inf)):
             if inf[j] > 0.0: activeInf.append(inf[j])
         if len(activeInf) > maxInf:
             returnVerts.append(i)
     
     if select:
         for vert in returnVerts:
             cmds.select((node + '.vtx[' + str(vert) + ']'), add=1)
     if debug:
         print 'checkMaxSkinInfluences>>> Total Verts:', verts
         print 'checkMaxSkinInfluences>>> Vertices Over Threshold:', len(returnVerts)
         print 'checkMaxSkinInfluences>>> Indices:', str(returnVerts)
     return returnVerts
开发者ID:chrisevans3d,项目名称:skinWrangler,代码行数:26,代码来源:skinWrangler.py


示例9: mtt_log

def mtt_log(msg, add_tag=None, msg_type=None, verbose=True):
    """ Format output message '[TAG][add_tag] Message content'

    :param msg: (string) message content
    :param add_tag: (string or list) add extra tag to output
    :param msg_type: define message type. Accept : None, 'warning', 'error'
    :param verbose: (bool) enable headsUpMessage output
    """
    # define tags
    tag_str = '[MTT]'

    # append custom tags
    if add_tag:
        if not isinstance(add_tag, list):
            add_tag = [add_tag]

        for tag in add_tag:
            tag_str += '[%s]' % tag.upper()

    # output message the right way
    if msg_type == 'warning':
        cmds.warning('%s %s' % (tag_str, msg))
    elif msg_type == 'error':
        cmds.error('%s %s' % (tag_str, msg))
    else:
        print '%s %s\n' % (tag_str, msg),

    if verbose and MTTSettings.value('showHeadsUp'):
        cmds.headsUpMessage(msg)
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:29,代码来源:mttCmd.py


示例10: __init__

    def __init__(self, srcMesh, influences ):
        
        srcMeshSkinCluters = sgCmds.getNodeFromHistory( srcMesh, 'skinCluster' )
    
        if not srcMeshSkinCluters:
            cmds.error( "%s has no skincluster" % srcMesh ); return
    
        fnSkinCluster = OpenMaya.MFnDependencyNode( sgCmds.getMObject( srcMeshSkinCluters[0] ) )
    
        self.influenceIndices = []
        for origPlug, influencePlug in pymel.core.listConnections( fnSkinCluster.name() + '.matrix', s=1, d=0, p=1, c=1 ):
            influenceName = influencePlug.node().name()
            if not influenceName in influences: continue
            self.influenceIndices.append( origPlug.index() ) 

        self.weightListPlug = fnSkinCluster.findPlug( 'weightList' )
        self.vtxIndex = 0
    
        self.weightsPlug = self.weightListPlug.elementByLogicalIndex( self.vtxIndex ).child(0)
        
        self.influenceWeights = {}
        for i in range( self.weightsPlug.numElements() ):
            weightPlug = self.weightsPlug.elementByPhysicalIndex( i )
            logicalIndex = weightPlug.logicalIndex()
            self.influenceWeights[ logicalIndex ] = weightPlug.asFloat()
开发者ID:jonntd,项目名称:mayadev-1,代码行数:25,代码来源:fingerWeightCopy.py


示例11: fxCombine

def fxCombine(merge=False):
    targets = m.ls(sl=True, l=True)

    if not targets:
        return

    parent = m.listRelatives(targets[0], p=True, pa=True)

    try:
        combineResult = m.polyUnite(targets)
    except RuntimeError:
        m.error('Invalid selection for combine operation.')
        return

    if parent:
        combineResult = m.parent(combineResult[0], parent[0])

    m.delete(combineResult[0], ch=True)

    for t in targets:
        if m.objExists(t):
            m.delete(t)

    finalObject = m.rename(combineResult[0], getShortName(targets[0]))
    m.select(finalObject)

    if merge:
        meval('performPolyMerge 0')
        m.polyOptions(finalObject, displayBorder=True, sizeBorder=4)
        m.select(finalObject)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:30,代码来源:fx_combine.py


示例12: getGrowIndices

 def getGrowIndices(self):
     
     util = OpenMaya.MScriptUtil()
     util.createFromInt( 1 )
     prevIndex = util.asIntPtr()
     
     if not self.checkedIndices:
         cmds.error( "checked indices is not exists" ); return []
 
     targetVtxIndices = []
     for i in range( len( self.checkedIndices ) ):
         checkedIndex = self.checkedIndices[i]
         intArrFaces = OpenMaya.MIntArray()
         self.itMeshVertex.setIndex( checkedIndex, prevIndex )
         self.itMeshVertex.getConnectedFaces( intArrFaces )
         for j in range( intArrFaces.length() ):
             faceIndex = intArrFaces[j]
             intArrVertices = OpenMaya.MIntArray()
             self.itMeshPolygon.setIndex( faceIndex, prevIndex )
             self.itMeshPolygon.getVertices( intArrVertices )
             for k in range( intArrVertices.length() ):
                 vtxIndex = intArrVertices[k]
                 if vtxIndex in self.checkedIndices: continue
                 targetVtxIndices.append( vtxIndex )
                 self.checkedIndices.append( vtxIndex )
     return targetVtxIndices
开发者ID:jonntd,项目名称:mayadev-1,代码行数:26,代码来源:fingerWeightCopy.py


示例13: fileSVNstatus

	def fileSVNstatus(self, status):
		# the status of the current file is assigned here and the following branching code handles the results
		status = self.SVN('status')
		if not runSVN:
			cmds.warning( 'SVN integration is currently disabled' )
		if runSVN:
			print 'SVN status is : -> ' + status
		if type(status) != str:
				return cmds.warning( 'scene has not been modified' )
		if status == 'A':
			# the file is added to svn but not modified, no need to commit
			return cmds.warning( 'there are no changes to this scene file.' )
		if status == 'C':
			# the file is added to svn but not modified, no need to commit
			return cmds.error( 'This file is conflicted!' )
		if status == 'M':
			# this section shold commit the file to SVN, after status return M for modified.
			if runSVN:
				SVN('commit ')
			return cmds.warning( 'modified file has been committed' )
		if status == '?':
			# if the status returns ?, which means the file is not added to SVN, then add the file.
			if runSVN:
				SVN('add ')
			return cmds.warning( 'scene has added to SVN and checked in.' )
		else:
			if runSVN:
				return cmds.error( 'Unhandled status ' + status )
开发者ID:ALstair,项目名称:styleExample,代码行数:28,代码来源:pipeline_functions.py


示例14: cmdRename

        def cmdRename( *args ):

            renameTarget = FolderSubRenameUiInfo._renameTarget
            path = cmds.textField( FolderUIInfo._fieldUI, q=1, tx=1 )

            srcPath = path + '/' + renameTarget
            if not os.path.exists( path + '/' + renameTarget ): cmds.error( '%s is not Exists' % srcPath )
            
            extension = renameTarget.split( '.' )[1]
            
            fieldName = cmds.textField( FolderSubRenameUiInfo._renameTextField, q=1, tx=1 )
            if not fieldName: return None

            destPath = path + '/'
            if os.path.exists( path + '/' + fieldName+'.'+extension):
                addNum = 0
                while os.path.exists( path + '/' + fieldName+str(addNum)+'.'+extension ):
                    addNum += 1
                destPath += fieldName+str(addNum)+'.'+extension
            else:
                destPath += fieldName+'.'+extension
            os.rename( srcPath, destPath )
            
            cmds.deleteUI( FolderSubRenameUiInfo._winName, wnd=1 )
            
            cmds.textScrollList( FolderUIInfo._scrollListUI, e=1, ri=renameTarget )
            cmds.textScrollList( FolderUIInfo._scrollListUI, e=1, a=fieldName+'.'+extension )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:27,代码来源:control.py


示例15: setPupilSize

def setPupilSize(*args):
    print args
    if len(gEyeballCtrler) == 0:
        cmds.error('Please set current eyeball controler.')
    else:
        gPupilValue = args[0]
        cmds.setAttr(gEyeballCtrler + '.pupilSize', gPupilValue)
开发者ID:raina-wu,项目名称:maya_plugin_diy,代码行数:7,代码来源:eyeball.py


示例16: jointFromList

def jointFromList(xformList=[], orient="xyz", secAxis="zup", strip="", suffix="", *args):
    """
    uses the xformlist arg (a list of transforms in scene) to create a joint chain in order.
    Arguments: xformList (a list), orient ("xyz", etc), secAxis ("xup", "zdown", etc), strip (string to strip off), suffix (string to add to the joints)
    """
    jointList = []

    #if no list is provided, get the list from selection order
    if not xformList:
        sel = getSelection()

        if sel:
            xformList = sel
        #if no list && no selection then throw error
        else:
            cmds.error("you must provide a list of transforms or have the transforms selected in order")

    #clear selection
    cmds.select(cl=True)
    #for each thing in the list create a joint at that location (they'll be parented to the previous)
    for xform in xformList:
        xformPos = cmds.xform(xform, q=True, ws=True, t=True)
        jointName = "%s%s"%(xform.rstrip(strip), suffix)
        thisJoint = cmds.joint(n=jointName, p=xformPos)
        jointList.append(thisJoint)

    #now orient the joint chain based on args and return a list of the joints
    cmds.joint(jointList[0], e=True, ch=True, oj=orient, sao=secAxis)
    return(jointList)
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:29,代码来源:zbw_rig.py


示例17: setIrisConcave

def setIrisConcave(*args):
    print args
    if len(gEyeballCtrler) == 0:
        cmds.error('Please set current eyeball controler.')
    else:
        gIrisConcaveValue = args[0]
        cmds.setAttr(gEyeballCtrler + '.irisConcave', gIrisConcaveValue)
开发者ID:raina-wu,项目名称:maya_plugin_diy,代码行数:7,代码来源:eyeball.py


示例18: blendScale

def blendScale(blend="none", sourceA="none", sourceB="none", target="none", sourceValue="none"):
	"""name is first arg, then three objects. Blends translation from first two selected into third selected. SourceValue (last input) is for the driving obj.attr. First source is active at '1', second at '2'"""
	#add input and *args
	if blend == "none":
		blend = "blendColors"
	if sourceA == "none":
		sel = getSelection()
		if len(sel) != 3:
			cmds.error("Error: blendRotation, select three transforms")
			#inert some kind of break here
		sourceA = sel[0]
		sourceB = sel[1]
		target = sel[2]
	blend = cmds.shadingNode("blendColors", asUtility=True, name=blend)
	sourceAOut = sourceA + ".scale"
	sourceBOut = sourceB + ".scale"
	targetIn = target + ".scale"
	blend1 = blend + ".color1"
	blend2 = blend + ".color2"
	blendOut = blend + ".output"
	cmds.connectAttr(sourceAOut, blend1)
	cmds.connectAttr(sourceBOut, blend2)
	cmds.connectAttr(blendOut, targetIn)
	if not sourceValue == "none":
		cmds.connectAttr(sourceValue, "%s.blender"%blend)

	return(blend)
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:27,代码来源:zbw_rig.py


示例19: saveRig

		def saveRig(self):
			"""
				Will save current rig if built in file
			"""
			# Check all modules are in rig mode
			modules = self.Modules.keys()
			for module in modules:
				if self.Modules[module].rigMode() != 1:
					cmds.error("Cannot save rig as not all modules are in rig mode")
			# If file exists prompt warning
			defaultFilePath = ( self.UI.getFilePath() + "rigFile/" + self.name )
			deatultFolderPath = ( self.UI.getFilePath() + "rigFile/" )
			
			# If folder doesn't exist create
			if os.path.exists( deatultFolderPath ) == False :
				os.makedirs( deatultFolderPath )
			
			cmds.file( rename= defaultFilePath )
			if os.path.exists( (defaultFilePath + ".ma") ):
				# prompt and save / exit
				self.UI.createPromptWindow("Overwrite old save?",("cmds.file( save = True, type='mayaAscii' )\nprint ( \"NWRig saved to: " + defaultFilePath+ ".ma\")") )
			else:
				# Save file
				cmds.file( save = True, type='mayaAscii' )
				print ( "Rig saved to: " + defaultFilePath + ".ma")
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:25,代码来源:NWRig.py


示例20: measureDistance

def measureDistance(mName="none", *args):
	"""first the name of the measure node, then the 2 objects ORRRR select the two objects and run (will give name 'distanceBetween'"""
	objs = []
	if mName == "none":
		mName = "distanceBetween"
		objs = getTwoSelection()
	else:
		for each in args:
			objs.append(each)
	#add check for 2 selectiont
	if len(objs) != 2:
		cmds.error("you must enter either a measure name and 2 objects OR no arguments and manually select 2 objs")
	dist = cmds.shadingNode("distanceBetween", asUtility=True, name=mName)
	objA = objs[0]
	objB = objs[1]
	objAMatrix = objA + ".worldMatrix"
	objBMatrix = objB + ".worldMatrix"
	objAPoint = objA + ".rotatePivot"
	objBPoint = objB + ".rotatePivot"
	distPoint1 = dist + ".point1"
	distPoint2 = dist + ".point2"
	distMatrix1 = dist + ".inMatrix1"
	distMatrix2 = dist + ".inMatrix2"
	cmds.connectAttr(objAPoint, distPoint1)
	cmds.connectAttr(objBPoint, distPoint2)
	cmds.connectAttr(objAMatrix, distMatrix1)
	cmds.connectAttr(objBMatrix, distMatrix2)
	cmds.select(clear=True)
	return(dist)
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:29,代码来源:zbw_rig.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cmds.evalDeferred函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.editRenderLayerGlobals函数代码示例发布时间: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