本文整理汇总了Python中pymel.core.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rig_makeBlockGeo
def rig_makeBlockGeo(meshes, constrain=False, *args):
'''
Args:
meshes (list(pm.nt.Transform)): meshes to cut up
constrain (boolean): whether to constrain them or not
Returns:
list (pm.nt.Transform): list of block geometries created
Usage:
rig_makeBlockGeo(pm.ls(sl=True), constrain=True)
'''
blockgeos=[]
joints=[]
for mesh in meshes:
skinCluster = rig_getConnectedSkinCluster(mesh)
if skinCluster:
joints+= skinCluster.getWeightedInfluence()
if len(joints)==1:
dup=pm.duplicate(mesh, n=mesh.name().replace('GEO','BLOCKGEO'))[0]
blockgeos.append(dup)
rig_unlockTransform(dup)
pm.parentConstraint(joints[0], dup, mo=True)
else:
for joint in joints:
blockgeo = rig_makeBlockGeoFromJoint([mesh], joint)
if blockgeo:
if pm.objExists(blockgeo):
blockgeos+=blockgeo
pm.delete(blockgeo, ch=True)
if constrain:
for geo in blockgeo:
rig_unlockTransform(geo)
pm.parentConstraint(joint, geo, mo=True)
else:
pm.warning('No skinCluster detected on mesh %s' % mesh)
return blockgeos
示例2: 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')
示例3: getCurrentTranslator
def getCurrentTranslator(self, nodeName):
"""
get the current translator for this node, querying and setting the default if not yet set
"""
try :
# asString allows for enum attributes as well
transName = pm.getAttr(nodeName + ".aiTranslator", asString=True)
except :
transName = None
translators = self.getTranslators()
if not transName or transName not in translators:
# set default
transName = getDefaultTranslator(nodeName)
if transName is None:
if not translators:
pm.warning("cannot find default translator for %s" % nodeName)
return
transName = translators[0]
try :
pm.setAttr(nodeName + ".aiTranslator", transName)
except:
pm.warning("cannot set default translator for %s" % nodeName)
import traceback
traceback.print_exc()
return transName
示例4: ReverseShape
def ReverseShape( objs=None, axis='x' ):
scaleValue = ( -1, 1, 1 )
if axis == 'y':
scaleValue = ( 1, -1, 1 )
elif axis == 'z':
scaleValue = ( 1, 1, -1 )
elif axis != 'x':
pm.warning('Axis was not correct, used "x" axis instead.')
if objs == None:
objs = pm.ls( sl=True )
else:
objs = pm.ls( objs )
for obj in objs:
try:
shape = obj.getShape()
if shape.type() == 'mesh':
pm.select( shape.vtx[:] )
pm.scale( scaleValue )
pm.select( objs )
elif shape.type() == 'nurbsCurve':
pm.select( shape.cv[:] )
pm.scale( scaleValue )
pm.select( objs )
except:
pm.warning("Object doesn't have a shape. Skipped!")
'''
示例5: setWipFolder
def setWipFolder(self):
currentScene = pm.sceneName()
if currentScene:
projectPath,fileName = os.path.split(currentScene)
wipFolder = ''
try:
wipFolder = pm.fileDialog2(dir=projectPath,ds=2,fm=3,okc='Select Folder')[0]
except:
pm.warning('No folder was selected')
if wipFolder:
self.wipFolderEdit.setText(wipFolder)
self.wipFolderPath = wipFolder
self.bdPopulateFiles()
else:
projectPath = pm.workspace.path
charactersFolder = os.path.abspath(os.path.join(projectPath,'scenes','characters'))
path = ''
try:
path = pm.fileDialog2(dir=charactersFolder,ds=2,fm=3,okc='Select Folder')[0]
except:
pm.warning('No folder was selected')
if path:
self.wipFolderEdit.setText(path)
self.wipFolderPath = path
self.bdPopulateFiles()
示例6: loadDeformerWeights
def loadDeformerWeights(filename=None):
'''
Usage:
loadDeformerWeights(filename='/jobs/mercedesFable_5402587/build/charTortoise/maya/export/WEIGHTS/tortoiseAFacial/extraWeights/deformerWeights/v03/deformerWeights.json')
loadDeformerWeights()
'''
if not filename:
try:
filename = pm.fileDialog2(cap='Select a json file you stored', fm=1, okc='Load', ff='JSON (*.json)')[0]
except:
pm.error('file not found, whatever.')
with open(filename, 'rb') as fp:
data = json.load(fp)
for key in data.keys():
if pm.objExists(key):
deformer = Deformer(pm.PyNode(key))
print 'Loading weights for deformer:\t%s'%deformer
for deformedShape in data[key].keys():
if pm.objExists(deformedShape):
print '\tLoading deformer weights on shape:\t%s'%deformedShape
deformedTransform = pm.PyNode(deformedShape).getParent()
#print data[key][deformedShape]
deformer.setWeights(data[key][deformedShape], deformedTransform)
else:
pm.warning('Object %s does not exist to apply deformer weights to...skipping'%deformedShape)
else:
pm.warning('Deformer %s doesn\'t exist...skipping'%key)
示例7: copyZoobeAnimations
def copyZoobeAnimations(self,zoobeChar):
print 'Importing Zoobe Animations'
if zoobeChar:
sourceChar = 'source:' + zoobeChar
fuseChar = self.name
rigFile = os.path.join(CHARACTERS_PATH,self.name,'rigging',self.name + '.ma')
zoobeCharFolder = os.path.join(ANIM_LIB_PATH,zoobeChar)
if os.path.isdir(zoobeCharFolder):
animFiles = [f for f in os.listdir(zoobeCharFolder) if (f.endswith('.ma') or f.endswith('.mb'))]
animFile = '/home/zoobe/mixamo/testproject/incoming/animLib/violet/violet_angry_action_01.ma'
#self.copyAnimation(animFile,sourceChar,fuseChar,0,300)
for anim in animFiles:
print animFile
animPath = os.path.join(zoobeCharFolder,anim)
print animPath
pm.openFile(animPath,f=1)
start = pm.playbackOptions(q=1,ast=1)
end = pm.playbackOptions(q=1,aet=1)
print start, end
self.copyAnimation(animPath,sourceChar,fuseChar,start,end)
print 'saving animation %s'%anim.split('.')[0]
self.saveAnimation(anim.split('.')[0])
else:
pm.warning('Did not find %s char folder'%zoobeChar)
示例8: add_to_bake_layer
def add_to_bake_layer( layer = None, objects = None ):
# Get the node for the bake Layer
layer_node = get_bake_layer( layer )
if layer_node == None:
pmc.error( 'add_to_bake_layer requires one "BakeLayer" node.')
# get the list of nodes for the objects
if objects == None:
pmc.warning( 'No objects specified, using selection' )
obj_list = pmc.ls( sl = True, typ = 'transform' )
elif isinstance( objects, pmc.nt.Transform ):
obj_list = [ objects ]
elif isinstance( pmc.PyNode( objects ), pmc.nt.Transform ):
obj_list = [ pmc.PyNode( objects ) ]
elif isinstance( object, [ tuple, list ] ):
obj_list = objects
else:
pmc.error( 'Objects supplied for add_to_bake_layer command were invalid' )
if len( obj_list ) < 1:
pmc.error( 'No valid objects were supplied or selected for the bake_layer_command' )
# Make connections
for obj in obj_list:
multi_connect(layer_node, 'lm', obj, 'bake')
示例9: ec_zero
def ec_zero(attr="all"):
selection = mc.ls(sl=True, type='transform')
try:
if attr == "sx" or attr == "sy" or attr == "sz":
for i in range(0, len(selection)):
mc.setAttr(selection[i]+"."+attr, 1.0)
elif attr == "s":
for i in range(0, len(selection)):
mc.setAttr(selection[i]+"."+attr, 1, 1, 1, type="double3")
elif attr == "all":
for i in range(0, len(selection)):
listat = mc.listAttr(selection[i], v=True, k=True)
print "listat :"
if listat is None:
print "ERROR: listat is None : %s" % selection[i]
else:
for k in range(0, len(listat)):
if listat[k] == "scaleX" or listat[k] == "scaleY" or listat[k] == "scaleZ" or listat[k] == "scale" or\
listat[k] == "visibility":
mc.setAttr(selection[i]+"."+listat[k], 1.0)
else:
mc.setAttr(selection[i]+"."+listat[k], 0.0)
else:
if attr == "t" or attr == "r":
for i in range(0, len(selection)):
mc.setAttr(selection[i]+"."+attr, 0.0, 0.0, 0.0, type="double3")
else:
for i in range(0, len(selection)):
mc.setAttr(selection[i]+"."+attr, 0.0)
py.headsUpMessage("Reset: %s attribute of object %s" % (attr, selection))
except:
py.warning("ERROR: %s attribute of %s is locked or otherwise unavailable to reset" % (attr, selection[i]))
示例10: uiAddWidgetSizeAnim
def uiAddWidgetSizeAnim(widget, onoff, size, size_offset=0):
size_anim = None
try:
print widget
size_anim = QtCore.QPropertyAnimation(widget, "geometry")
except:
pm.warning("Failed to create QPropertyAnimation ")
geometry = widget.geometry()
width = geometry.width()
x, y, _, _ = geometry.getCoords()
size_start = QtCore.QRect(x, y, width, int(not (onoff)) * size + size_offset)
size_end = QtCore.QRect(x, y, width, onoff * size + size_offset)
size_anim.setStartValue(size_start)
size_anim.setEndValue(size_end)
size_anim.setDuration(200)
size_anim_curve = QtCore.QEasingCurve()
if onoff:
size_anim_curve.setType(QtCore.QEasingCurve.InQuad)
else:
size_anim_curve.setType(QtCore.QEasingCurve.OutQuad)
size_anim.setEasingCurve(size_anim_curve)
return size_anim
示例11: FindDeformers
def FindDeformers ( shape=None , type=''):
if shape==None:
obj = pm.ls(sl=True)[0]
shape = obj.getShape()
if shape :
# List Deformers
history = pm.listHistory( shape, pruneDagObjects=True, interestLevel=2 )
deformers = []
for node in history :
nodeTypes = pm.nodeType( node, inherited=True )
if 'geometryFilter' in nodeTypes:
if type=='' and nodeTypes[1] != 'tweak' :
deformers.append(node)
elif nodeTypes[1] == type and nodeTypes[1] != 'tweak':
deformers.append(node)
return deformers
else:
pm.warning('No shape found.')
示例12: RigFK
def RigFK( jnts=None, side='L', ctrlSize=1.0, stretch=True, color='r' ):
if not jnts:
jnts = pm.ls( sl=True )
else:
jnts = pm.ls( jnts )
# find color of the ctrls
color = 'y'
if side == 'L':
color = 'r'
elif side == 'R':
color = 'b'
shapes = []
for jnt in jnts:
if not jnt or not jnt.type()=='joint':
pm.warning('ehm_tools...RigFK: %s was not a joint, skipped!'%jnt)
shapes.append( (JntToCrv ( jnts = jnt , size = ctrlSize )).newShapes )
LockHideAttr( objs=jnt, attrs='t' )
LockHideAttr( objs=jnt, attrs='radius' )
if stretch == True:
# add length attribute and connect it to scale
pm.addAttr ( jnt , ln = "length" , at = "double" , min = 0 , dv = 1 , k = True )
jnt.length >> jnt.scaleX
LockHideAttr( objs=jnt, attrs='s' )
Colorize( shapes=shapes, color=color )
return shapes
示例13: save_poseDeformerList
def save_poseDeformerList(obj):
'''stores poseDeformer files for the curreitnnt object
Args:
obj (pm.PyNode): the object to get deformers from
Returns (boolean): whether the export worked on not
Usage:
save_poseDeformerList(pm.ls(sl=True)[0])
'''
poseDeformers = get_connectedPoseDeformers(obj)
if poseDeformers:
folder = os.path.join( environ.POSEDEFORMERS, obj )
versionFolder = lib_env.folder_detectVersions( folder, versionUp=True )
if versionFolder:
folder = versionFolder
else:
folder = os.path.join(folder, 'v001')
if not os.path.exists(folder):
os.makedirs(folder)
for poseDeformer in poseDeformers:
file = os.path.join(folder, poseDeformer+'.ma')
command = 'poseDeformer_export(\"%s\", \"%s\", -1)'%(poseDeformer,file)
print command
eval( command )
else:
pm.warning('Object %s has no pose deformers attached to it...'%obj)
示例14: vPrint
def vPrint(txt, verb=2, type=0):
"""global verbose print function
# gVerb = 2 print each step
# gVerb = 1 print problemes
# gVerb = 0 print nothing
# type = 0 print
# type = 1 warning
# type = 2 error
"""
global gVerb
if verb <= gVerb:
# to properly distinguish probleme from everything else
if verb == 1:
start = '\t1# '
else:
start = '\t # '
# and then print everything
if type == 0:
print start + txt
elif type == 1:
pmc.warning(start + txt)
else:
pmc.error(start + txt)
示例15: get_sel_nucleus
def get_sel_nucleus(self):
print 'get_sel_nuclues'
cmd = 'ls -sl -dag -lf -l -type nucleus'
self.Nucleus = pm.mel.eval(cmd)
if not self.Nucleus:
pm.warning('select some nuclues first.')
print self.Nucleus