当前位置: 首页>>代码示例>>Python>>正文


Python cmds.error函数代码示例

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


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


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