本文整理汇总了Python中maya.cmds.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: keyToOn
def keyToOn():
controller = mc.ls(sl=True)[0]
channelBox = mel.eval('global string $gChannelBoxName; $temp=$gChannelBoxName;') #fetch maya's main channelbox
attrs = mc.channelBox(channelBox, q=True, sma=True)
if attrs:
channel = controller + "." + attrs[0]
constraint = mc.listConnections(channel, type="constraint")[0]
currentTime = mc.currentTime( query=True )
# save rest pose on constraint
# mc.currentTime(currentTime-1)
constraintChannels = mc.listConnections(constraint, type="animCurve")
mc.parentConstraint(controller, constraint, edit=True, maintainOffset=True)
for i in constraintChannels:
value = mc.getAttr(mc.listConnections(i, plugs=True)[0])
setKeyframe(mc.listConnections(i, plugs=True)[0], currentTime, value)
# set key on 1 for controller
setKeyframe(channel, currentTime-1, value=0)
setKeyframe(channel, currentTime, value=1)
# mc.currentTime( currentTime )
else:
mc.warning("Select constrain channel!")
示例3: _get_recommended_pivot_bank
def _get_recommended_pivot_bank(self, geometries, tm_ref, tm_ref_dir, pos_toes, direction=1):
"""
Determine recommended position using ray-cast from the toes.
TODO: If the ray-case fail, use a specified default value.
return: The recommended position as a world pymel.datatypes.Vector
"""
# Sanity check, ensure that at least one point is in the bounds of geometries.
# This can prevent rays from being fired from outside a geometry.
# TODO: Make it more robust.
filtered_geometries = []
for geometry in geometries:
xmin, ymin, zmin, xmax, ymax, zmax = cmds.exactWorldBoundingBox(geometry.__melobject__())
bound = pymel.datatypes.BoundingBox((xmin, ymin, zmin), (xmax, ymax, zmax))
if bound.contains(pos_toes):
filtered_geometries.append(geometry)
dir = pymel.datatypes.Point(direction, 0, 0) * tm_ref_dir
pos = libRigging.ray_cast_nearest(pos_toes, dir, filtered_geometries)
if not pos:
cmds.warning("Can't automatically solve FootRoll bank inn pivot.")
pos = pos_toes
pos.y = 0
return pos
示例4: get_num_cvs
def get_num_cvs(self, curve):
'''
Desc:
Get cvs lenght from a curve
Parameter:
curve = curve to get cvs positin list from
coords_space = the coordinat space, can be "world" (default), or "local"
Return:
list with positions
'''
# If curve is nod define or not correct release error
if curve:
# Get curve shape
curve_shape = KstMaya.get_shape_node(curve)
# Get degree
degree = cmds.getAttr(curve_shape+".degree")
# Get spans
spans = cmds.getAttr(curve_shape+".spans")
# Calulating ncvs with formula spans+degree
ncvs = spans+degree
# Return the list
return ncvs
else:
cmds.warning("Curve %s, is not defined, or is not a curve, double check!" % curve)
return None
示例5: saveFileToPublish
def saveFileToPublish(self):
self.currentFilePath = cmds.file(q=1, sn=1)
if self.currentFilePath:
if '/work/' in self.currentFilePath:
self.baseName = os.path.basename(self.currentFilePath)
self.publishPath = self.currentFilePath.split(self.baseName)[0].replace('/work/', '/publish/')
self.publishFilePath = os.path.join(self.publishPath, self.baseName)
if os.listdir(self.publishPath):
fileName = sorted(os.listdir(self.publishPath))[-1].replace('.ma', '.mb')
newPublishFilePath = os.path.join(self.publishPath, fileName)
curVersion = os.path.splitext(fileName)[0].split('.v')[-1]
newVersion = int(curVersion) + 1
newVersionStr = '.v%03d' % newVersion
self.publishFilePath = newPublishFilePath.replace('.v%03d' % int(curVersion), newVersionStr)
cmds.file(f=1, save=1)
cmds.file(rename=self.publishFilePath)
cmds.file(f=1, save=1, type = 'mayaBinary')
cmds.file(self.currentFilePath, f=1, open=1)
return self.publishFilePath
else:
fileName = self.baseName.replace('.ma', '.mb')
newPublishFilePath = os.path.join(self.publishPath, fileName)
self.publishFilePath = newPublishFilePath
cmds.file(f=1, save=1)
cmds.file(rename=self.publishFilePath)
cmds.file(f=1, save=1, type = 'mayaBinary')
cmds.file(self.currentFilePath, f=1, open=1)
return self.publishFilePath
else:
cmds.confirmDialog(m="File is not in work directory.. Kindly save your file in work directory and run this script", b="Ok")
else:
cmds.warning('Cannot find proper file. Please save our file and proceed....')
示例6: offsetCurveDragCmd
def offsetCurveDragCmd(self, *args ):
if not self._dragStart:
selCurves = cmds.ls( sl=1 )
self._targetCurves = []
self._keepTargetCurveValues = []
for curve in selCurves:
if cmds.attributeQuery( 'centerRate' , node = curve, ex=1 ):
self._targetCurves.append( curve )
self._keepTargetCurveValues.append( cmds.getAttr( curve+'.centerRate' ) )
if not self._targetCurves:
cmds.warning( "Select VolumeCurves" )
return None
self._dragStart = True
cmds.undoInfo( swf=0 )
multRate = cmds.floatSliderGrp( self._offsetCurve, q=1, v=1 )
for i in range( len( self._targetCurves ) ):
targetCurve = self._targetCurves[i]
value = self._keepTargetCurveValues[i]
cmds.setAttr( targetCurve+'.centerRate', value*multRate )
示例7: publish
def publish():
# Import Modules
import shutil
# Get SceneName and Root
fullName = cmds.file(sceneName=True, q=True)
paths = fullName.split("/")
taskName = paths[-2].split("_")[2]
assetCode = paths[-2].split("_")[1]
assetName = Assets.getFullName(assetCode)
outFolder = "/".join(paths[:-1]) + "/" + assetCode + "_" + taskName + "_OUT"
outName = assetName + "_" + taskName
cmds.file( save=True, type='mayaAscii' ) # Save File
shutil.copy2(fullName, outFolder + "/" + outName + ".ma") # Copy File to MASTER
cmds.warning("[Kroentlied Pipeline] Published !")
# Copy File to BackUp
oldFolder = outFolder + "/" + assetCode + "_" + taskName + "_OUT_OLD"
backup = VersionControl.getLatest(oldFolder, 1)
if not backup: # No Backup found yet
backup = outName + "_BackUp_v001.ma"
shutil.copy2(fullName, oldFolder + "/" + backup)
print "[Kroentlied Pipeline] PublishBackup: " + backup
return
示例8: cb_drawLines
def cb_drawLines(self, x=None) :
if None in [ self.markerset, self.prefix ] :
m.warning("No markerset or prefix")
return
print "drawing lines for " + str(self.prefix)
self.markerset.drawLines( self.prefix )
示例9: 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
# parse arguments and get flags
argData = om.MArgParser (self.syntax(), argList)
axisOrder = argData.flagArgumentString('axisOrder', 0) if (argData.isFlagSet('axisOrder')) else 'yzx'
fast = argData.flagArgumentBool('fast', 0) if (argData.isFlagSet('fast')) else False
# get eigenvectors as matrix (column-wise), reshape matrix and append extra row/column
eig = np.matrix(cmds.eigenvector(obj, ao = axisOrder, f = fast))
eig.shape = (3,3)
eig = np.append(eig, [[0,0,0]], axis = 0)
eig = np.append(eig.transpose(), [[0,0,0,1]], axis = 0).transpose()
# return 4x4 matrix as 16 float values
util = om.MScriptUtil()
util.createFromList(eig.getA1().tolist(), eig.size)
self.setResult(om.MDoubleArray(util.asDoublePtr(), eig.size))
示例10: prepare
def prepare(setname="cache_set", groupname="cache_group", prefix="cache_"):
selection = cmds.ls(sl=True, l=True)
if len(selection) == 0:
cmds.warning("Please select objects!")
return
cmds.duplicate()
dup = cmds.ls(sl=True, l=True)
if cmds.objExists(groupname):
cmds.parent(dup, groupname)
else:
cmds.group(w=True, n=groupname)
cmds.select(groupname)
dup = get_shapes()
add_to_set_of_shapes(setname, dup)
i = 0
for obj in dup:
cmds.blendShape([selection[i], obj], w=(0, 1),o="world", foc=True)
objects = []
objects.append(obj)
addattr(objects, prefix+str(i))
i=i+1
示例11: on_getObjectRegion_pressed
def on_getObjectRegion_pressed(self):
sel=cmds.ls(selection=True)
#checking selection for meshes
check=False
for node in sel:
shape=cmds.listRelatives(node,shapes=True)
if shape:
if cmds.nodeType(shape)=='mesh':
check=True
if check:
regions=utils.getMeshAnimation()
regionNode=self.getSelectedRegionNode()
for r in regions:
utils.setRegionNode(regionNode, r)
else:
cmds.warning('Nothing selected. Please select one or more meshes!')
示例12: rootsOnPath
def rootsOnPath(path='X:/_image/_projects/SI/HOL/_Assets/ScareCrow/scenes/Anim_Asset/Path_v01.ma', reverse=False):
allLocs = []
roots = rootList()
if not nsPaths():
cn.uiEnable(controls='modelPanel')
roots = nsHollow(roots)
for root in roots:
nsA = nsPaths()
cmds.file(path, r=True, type="mayaAscii", gl=True, loadReferenceDepth="all", mergeNamespacesOnClash=False, namespace="Path_v01")
nsB = nsPaths()
ns = list(set(nsB) - set(nsA))[0]
# segments off
segmentsOff(ns=ns)
cmds.select(root)
cmds.select(ns + ':path', add=True)
# pose the path
pathPose(root=root, ns=ns)
# attach
allLocs.append(attach(up=ns + ':up', reverse=reverse))
# break
cn.uiEnable(controls='modelPanel')
for locs in allLocs:
cmds.select(locs, add=True)
else:
cmds.warning('-- remove all path rigs before starting --')
示例13: window
def window(dismiss):
if dismiss == "load":
self.loadData()
else:
cmds.warning("If you want to load later, go to aTools menu/Animation Crash Recovery option box")
self.saveBackup()
示例14: loadSel
def loadSel(self,tF,loadNum):
sels = cmds.ls(sl = True)
if len(sels) == loadNum:
sel = sels[0]
cmds.textField(tF,e = True,text = str(sel))
else:
cmds.warning ('place Load --' + str(loadNum) + ' --objects')
示例15: TappInstall_browse
def TappInstall_browse(*args):
repoPath=cmds.fileDialog2(dialogStyle=1,fileMode=3)
if repoPath:
repoPath=repoPath[0].replace('\\','/')
check=False
#checking all subdirectories
for name in os.listdir(repoPath):
#confirm that this is the Tapp directory
if name=='Tapp':
check=True
if check:
#create the text file that contains the Tapp directory path
path=cmds.internalVar(upd=True)+'Tapp.yml'
f=open(path,'w')
data='{launchWindowAtStartup: False, repositoryPath: \''+repoPath+'\'}'
f.write(data)
f.close()
#run setup
sys.path.append(repoPath)
cmds.evalDeferred('import Tapp')
#delete ui
cmds.deleteUI('TappInstall_UI')
else:
cmds.warning('Selected directory is not the \'Tapp\' directory. Please try again')