本文整理汇总了Python中pymel.core.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: locInst_locSel
def locInst_locSel(self):
'''
Function: Takes a locator and instances it's target (set as an extra attr)
Then sets the location of the instance.
If the instance already exists it uses that
Returns: None
'''
locs = pm.ls(sl=True)
grp_name = "_".join(locs[0].getParent().split('_')[:-2])+"_INST_GRP"
print grp_name
print pm.objExists(grp_name)
if pm.objExists(grp_name): pm.PyNode(grp_name)
else: grp=pm.group(em=True, n=grp_name)
for loc in locs:
#if the target isn't an instance create it
targetExists = pm.ls(loc.target.get().split('_')[:-1][0]!='GEO', r=True, type='transform')[0]
instanceExists = pm.ls(loc.target.get().split('_')[:-1][0]!='INST', r=True, type='transform')[0]
if not instanceExists and targetExists:
matchObj = pm.ls(loc.target.get(), r=True, type='transform')[0]
instance = pm.instance(matchObj, n=('_'.join(matchObj.split('_')[:-1])+'_INST'))[0]
#set the target to the new instance since it was created
loc.target.set(instance)
elif pm.objExists(loc.target.get()) and pm.objExists('_'.join(target.split('_')[:-1])+'_INST'):
pm.error('Neither a GEO nor an INST object exists with this name')
#otherwise initialize the instance variable
else: instance = pm.PyNode('_'.join(arg.split('_')[:-1])+'_INST')
loc.t.connect( instance.t )
loc.r.connect( instance.r )
loc.s.connect( instance.s )
instance.setParent(grp)
示例2: copyAnim
def copyAnim(self):
animFiles = []
f=''
wipPath = self.wipFolderEdit.text()
selectedItems = self.wipAnimTable.selectedItems()
if len(selectedItems):
for item in selectedItems:
if item.column() ==0:
anim = item.text()
print anim
src = os.path.abspath(os.path.join(wipPath,anim))
destPath = wipPath.replace('01_wip','03_preview')
dest = os.path.abspath(os.path.join(destPath,anim))
if os.path.isfile(src):
if os.path.isfile(dest):
pm.warning('Preview file exists already, will not overwrite ( save new version ? )')
else:
try:
shutil.copyfile(src, dest)
except:
pm.error('Could not copy anim file to preview')
self.bdPopulateFiles()
示例3: copyPlayblast
def copyPlayblast(self):
blastFiles = []
f=''
wipPath = self.wipFolderEdit.text()
selectedItems = self.wipAnimTable.selectedItems()
if len(selectedItems):
for item in selectedItems:
if item.text() == 'Yes':
animFile = self.wipAnimTable.item(item.row(),0).text()
blastFile = self.hasPlayblast(animFile)
wipBlastPath,blastFileName = os.path.split(blastFile)
destPath = wipPath.replace('01_wip','03_preview')
if destPath == wipPath:
destPath = wipPath.replace('01_WIP','03_PREVIEW')
dest = os.path.abspath(os.path.join(destPath,blastFileName))
if os.path.isfile(blastFile):
if os.path.isfile(dest):
pm.warning('Blast exists already, will not overwrite ( save new version ? )')
else:
try:
print("copying")
shutil.copyfile(blastFile, dest)
try:
os.remove(blastFile)
except OSError:
pass
self.bdPopulateFiles()
except:
pm.error('Could not copy blast file to preview')
示例4: storeDeformerWeights
def storeDeformerWeights(selection=True, type='rig_vertSnap'):
'''
Usage:
storeDeformerWeights(selection=False)
storeDeformerWeights(selection=True, type=['rig_vertSnap'])
storeDeformerWeights(selection=False, type=['rig_vertSnap', 'wire'])
'''
deformers = pm.ls(type=type)
if selection:
if len(pm.ls(sl=True))==0:
pm.error('select something numbnuts!')
deformers = pm.ls(sl=True)[0].listHistory(type='rig_vertSnap')
vsFile = {}
for deformer in deformers:
vs = Deformer(deformer)
vs.initializeWeights()
if len(vs.weightsList) > 0:
vsFile[deformer.name()] = vs.weightsList
try:
filename = os.path.join( pm.fileDialog2(cap='Select a folder to store the weights', fm=3, okc='Select')[0], 'deformerWeights.json' )
except:
pm.error('Why did you cancel? :(')
with open(filename, 'wb') as fp:
print 'Storing weights in file:\n\t%s'%(filename)
print '\t\tDeformers Stored:\n\t\t\t%s'%('\n\t\t\t'.join([deformer.name() for deformer in deformers]))
json.dump(vsFile, fp, indent=4)
示例5: importMixamoFbx
def importMixamoFbx(self) :
print 'importMixamoFbx'
pm.newFile(f=1)
if self.fbxFile:
if os.path.isfile(self.fbxFile):
#import the FBX file
pm.mel.eval( 'FBXImport -f "' + (self.fbxFile) + '"')
#check for a default mesh in T-Pose. If found, replace geometry
self.replaceGeometry()
#clean its namespace
removeNamespace()
hips = pm.ls("Hips",type='joint')
#add root joint for scale
rootJnt = pm.joint(n='Root')
pm.parent(hips[0],rootJnt)
#clean up textures
self.cleanUpTextures()
pm.currentUnit(t='ntsc')
return 1
else:
pm.error('Fbx file %s doesn\'t exist'%self.fbxFile)
return 0
else:
pm.error('No file was given')
return 0
示例6: _get_vert_weight_dict
def _get_vert_weight_dict() :
sel = pm.ls( sl=True )
if( len( sel ) != 1 ) :
pm.error( 'Please select ONE mesh transform' )
mesh = sel[0]
if( mesh.type() != 'transform' ) :
pm.error( 'Please select a MESH TRANSFORM' )
# get the skincluster
skinclusters = []
for node in pm.listHistory( mesh ) :
if( type( node ) == pm.nodetypes.SkinCluster ) :
skinclusters.append( node )
vertweightdict = {}
for skincluster in skinclusters :
for joint in skincluster.getWeightedInfluence() :
verts, weights = skincluster.getPointsAffectedByInfluence( joint )
for i, vert in enumerate( verts[0] ) :
weight = weights[i]
if( not vert in vertweightdict.keys() ) :
vertweightdict[ vert ] = []
vertweightdict[ vert ].append( ( joint, weight ) )
return vertweightdict, skinclusters
示例7: run_cmd_ui
def run_cmd_ui(self, *arg):
if self.py_path:
self.clear_script_reporter()
self.cmds[0] = self.user_cmd
cmd = ""
with codecs.open(self.py_path, encoding="utf-8", mode="r") as f:
cmd = f.read()
if cmd:
cmd += u"\n" + self.user_cmd
with codecs.open(self.exec_path, encoding="utf-8", mode="w") as f:
f.write(cmd)
try:
execfile(self.exec_path, globals())
except Exception, error:
traceback.print_exc(file=sys.stdout)
if "encoding declaration in Unicode string" == error.args[0]:
try:
exec(cmd.encode("cp850"))
except Exception, error:
pmc.error(error)
traceback.print_exc(file=sys.stdout)
else:
pmc.error(error)
示例8: _finalize
def _finalize(self, type):
nparticles = pm.ls(sl=True)
for nparticle in nparticles:
if pm.objectType(nparticle.getShape()) != 'nParticle':
nparticles.remove(nparticle)
print nparticles[0].getShape()
nparticle=[nparticles[0], nparticles[0].getShape()]
emitterCons = nparticle[1].listConnections(type='pointEmitter')
if emitterCons:
emitter = nparticle[1].listConnections(type='pointEmitter')[0]
else:
pm.error('The particle doesn\'t have an emitter connected')
if type==0:
#set the max particles + emitter to max
nparticle[1].maxCount.set(nparticle[1].getCount())
emitter.rate.set(20000) #arbitrary high value
print 'Setting max particle count for %s to %s' % (nparticle[1].name(), nparticle[1].getCount())
mm.eval("setNClothStartState")
mm.eval("performSetNClothStartState(1)")
if type==1:
#reset the max particles + emitter rate
mm.eval("clearNClothStartState")
mm.eval("performSetNClothStartState 0")
nparticle[1].maxCount.set(-1)
emitter.rate.set(5000)
示例9: __init__
def __init__(self, skinCluster=None, transform=None, verbose=0):
#Conditional argument setting
if verbose: print dir(skinCluster)
if transform:
if transform.getShape().listHistory(type='skinCluster'):
skinCluster = transform.getShape().listHistory(type='skinCluster')[0]
if verbose: print 'Found skinCluster connected to transform: %s'%skinCluster
else:
pm.warning('no skinCluster found on transform %s'%transform)
skinCluster = None
if transform==None and skinCluster==None:
pm.error('You have to specify either a skinCluster or a transform')
#generating information
self.skinCluster = skinCluster
if self.skinCluster:
self.node = self.skinCluster.node()
self.shape = self.skinCluster.getGeometry()[0]
self.transform = self.shape.getParent()
self.outputMesh = self.skinCluster.getOutputGeometry()
self.inputMesh = self.skinCluster.getInputGeometry()
self.weights = self._convertWeightsToList( self.skinCluster.getWeights( self.shape ) )
self.influences = self.skinCluster.getInfluence()
else:
self.node = None
self.shape = None
self.transform = None
self.outputMesh = None
self.inputMesh = None
self.weights = []
self.influences = []
示例10: FindPVposition
def FindPVposition( objs=pm.ls(sl=True) ):
if not len(objs) == 3:
pm.error( 'ehm_tools...findPVposition: objs arguments takes exactly 3 objects. %s was given.'%len(objs) )
base = objs[0]
mid = objs[1]
tip = objs[2]
A = dt.Vector( pm.xform( base, q=True, t=True, ws=True ) )
B = dt.Vector( pm.xform( mid, q=True, t=True, ws=True ) )
C = dt.Vector( pm.xform( tip, q=True, t=True, ws=True ) )
AC = C - A
AB = B - A
D = A + ( (dt.dot(AB,AC.normal())) * AC.normal() ) # AB projected on AC
position = B + B - D
if (position[0] - B[0] < 0.001) and (position[1] - B[1] < 0.001) and (position[2] - B[2] < 0.001):
pm.warning( 'ehm_tools...FindPVposition: Limbs were straight. None was returned!' )
return None
else:
return position
示例11: create_follicle
def create_follicle(transform, name=None, uPos=0.0, vPos=0.0):
""" Create a follicle at u and v position (if polygon mesh, needs UV coords)
Args:
transform (pm.nt.Transform): PyNode transform of mesh
Returns (pm.nt.Follicle): the resulting follicle
Usage:
create_follicle(pm.ls(sl=True)[0], uPos=0.5, vPos=0.5)
"""
shape = transform.getShape()
print type(shape) == pm.nodetypes.Mesh
if type(shape) not in [pm.nodetypes.Mesh, pm.nodetypes.NurbsSurface]:
pm.error("You need to specify a mesh of type nurbs or poly, incorrect mesh specified")
if not name:
name = transform.name() + "_FOL"
follicle_shp = pm.createNode("follicle", name=name)
follicle_xfm = follicle_shp.getParent()
# One different connection for poly/nurbs then all connections
# (The polygons will need to have UVs in order to work.)
if type(shape) == pm.nodetypes.Mesh:
shape.outMesh.connect(follicle_shp.inputMesh)
else:
shape.local.connect(shape.inputSurface)
shape.worldMatrix[0].connect(follicle_shp.inputWorldMatrix)
follicle_shp.outRotate.connect(follicle_xfm.rotate)
follicle_shp.outTranslate.connect(follicle_xfm.translate)
# Now setup attributes
follicle_shp.parameterU.set(uPos)
follicle_shp.parameterV.set(vPos)
follicle_xfm.t.lock()
follicle_xfm.r.lock()
return follicle
示例12: _attachRenderProxy
def _attachRenderProxy( self, objects ):
path = self.fileInput.text()
proxy = []
if os.path.isdir(path):
for file in glob.glob(path+"/*.mib"):
bipx = pm.createNode('mip_binaryproxy',n=file.split('/').pop().split('.')[0]+'_BINARYPROXY')
bipx.object_filename.set(file)
proxy.append(bipx)
else:
bipx = pm.createNode('mip_binaryproxy',n=path.split('/').pop().split('.')[0]+'_BINARYPROXY')
bipx.object_filename.set(path)
proxy.append( bipx )
if not objects:
for prx in proxy:
objects.append(pm.polyCube())
for arg in objects:
if len(proxy)==0: pm.error('No proxies found in folder. Womp Womp.')
elif len(proxy)>1:
print 'more than one proxy'
#turn the lo geometry shader on
arg.miExportGeoShader.set(1)
#connect the proxy to the lo's geo shader
proxy[random.randint(0,len(proxy)-1)].outValue.connect(arg.miGeoShader, f=True)
else:
print 'one proxy'
#turn the lo geometry shader on
arg.miExportGeoShader.set(1)
#connect the proxy to the lo's geo shader
proxy.pop().outValue.connect(arg.miGeoShader, f=True)
示例13: importMixamoFbx
def importMixamoFbx(self):
print "importMixamoFbx"
pm.newFile(f=1)
if self.fbxFile:
if os.path.isfile(self.fbxFile):
# import the FBX file
pm.mel.eval('FBXImport -f "' + (self.fbxFile) + '"')
# clean its namespace
removeNamespace()
# self.logger.info('Imported file %s',self.fbxFile)
hips = pm.ls("Hips", type="joint")
# add root joint for scale
rootJnt = pm.joint(n="Root")
pm.parent(hips[0], rootJnt)
# self.logger.info('Added root joint %s',rootJnt)
# clean up textures
self.cleanUpTextures()
pm.currentUnit(t="ntsc")
# add shadow plane
return 1
else:
pm.error("Fbx file %s doesn't exist" % self.fbxFile)
return 0
else:
pm.error("No file was given")
return 0
示例14: _removeInBetweenNode
def _removeInBetweenNode(self):
args = pm.ls(sl=True)
for arg in args:
#store the connections
arg_inputs_raw = arg.listConnections(scn=True, s=False, p=True)
arg_outputs = arg.listConnections(scn=True, d=False, p=True)
print arg_outputs
print arg_inputs_raw
#check if there are no connections on either side
if not len(arg_outputs) or not len(arg_inputs_raw):
pm.error('Object is not connected on both sides numbnuts')
#sort out unliked node types
arg_inputs=[]
for arg_input in arg_inputs_raw:
for not_accept in ['initial', 'default']:
add=1
if not_accept in arg_input.name():
add=0
break
if add: arg_inputs.append(arg_input)
#remove the old connection input
arg.listConnections(c=True,d=False,p=True)[0][0].disconnect()
#connect the two originals if they're the same type
print "input is %s, output is %s" % (arg_inputs[0], arg_outputs[0])
print arg_inputs[0].type()
print arg_outputs[0].type()
if (arg_inputs[0].type() == arg_outputs[0].type()):
arg_outputs[0].connect(arg_inputs[0], f=True)
else: pm.error('Connections don\'t match!', sl=True)
示例15: convertLightmapSequence
def convertLightmapSequence(ast, aet, res, occres, fileFormat, falloff=0.0):
'''The first selected object will bake occlusion to it, with all other selected as inputs
It automatically bakes to the "maya/sourcimages/occlusionBake/" folder and auto-versions
Args:
ast (int): animation start time
aet (int): animation end time
res (int): resolution for the map to bake
occres (int): resolution for the occlusion
fileFormat (string): accepts: TIFF,IFF,JPG,RGB,RLA,TGA,BMP,HDR
falloff (float): float for controlling AO falloff
Returns (None)
Example: convertLightmapSequence(1,5,256,32)
'''
sel=pm.ls(sl=True, type='transform')
extension = {'TIFF':0,'IFF':1,'JPG':2,'RGB':3,'RLA':4,'TGA':5,'BMP':6,'HDR':7}
pathBase = "/jobs/{JOB}/{SHOT}/{MAYA}/{OBJ}".format(JOB = os.getenv('JOB'),
SHOT = os.getenv('SHOT'),
MAYA='maya/sourceimages/occlusionBake',
OBJ=sel[0])
#Create and add objects to the bakeSet
if len(sel)>0:
if not pm.objExists('tmpBakeSet'):
bakeSet = pm.createNode('textureBakeSet', n='tmpBakeSet')
else:
bakeSet = pm.PyNode('tmpBakeSet')
else:
pm.error('No objects selected...')
for obj in sel:
bakeSet.add(obj.getShape())
#Set the shit for the bakeSet
bakeSet.xResolution.set(res)
bakeSet.yResolution.set(res)
bakeSet.colorMode.set(3)
bakeSet.occlusionRays.set(occres)
bakeSet.bakeToOneMap.set(1)
bakeSet.fileFormat.set(extension[fileFormat])
bakeSet.occlusionFalloff.set(falloff)
#Version up the folder and now that's the pathBase
if not os.path.exists(pathBase):
os.makedirs(pathBase)
folders = [folder for folder in os.listdir(pathBase) if os.path.isdir(os.path.join(pathBase, folder))]
version = 'v%03d'% (len(folders)+1)
if len(folders)==0:
version = 'v001'
pathLgt = os.path.join(pathBase,version)
pathBase = os.path.join(pathBase,version,'lightMap')
if not os.path.exists(pathBase):
os.makedirs(pathBase)
#Now finally bake
for frame in range(ast,aet+1):
bakeSet.prefix.set('occBake%04d'%frame)
pm.currentTime(frame)
pm.convertLightmap('initialShadingGroup', sel[0], camera='persp', prj=pathLgt, sh=True, bo=bakeSet)
#Get dat selection bak
pm.select(sel, r=True)