本文整理汇总了Python中maya.cmds.confirmDialog函数的典型用法代码示例。如果您正苦于以下问题:Python confirmDialog函数的具体用法?Python confirmDialog怎么用?Python confirmDialog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了confirmDialog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dynamicChainCmd
def dynamicChainCmd(*args):
'''
Get information and create dynamic joint chain network
'''
from time import gmtime, strftime
verified = True
log = ""
# get the selected joints
joints = cmds.ls(sl=True)
if len(joints) != 2:
log += "- Need to select the start joint and the end joint\n"
verified = False
if verified:
# create class instance
dynChain = lpDynamicChain(joints[0], joints[1])
# create the dynamic network
nodes = dynChain.create()
if nodes:
dateTime = strftime("%a, %b %d %Y - %X", gmtime())
nodesString = ""
# build string for feedback
for i,node in enumerate(nodes):
nodesString += "%d. %s\n" % (i,node)
cmds.confirmDialog(messageAlign="left", title="lpDynamicChains", message="%s\n------------------\n\nNew dynamic nodes:\n\n%s\n\nThank you!" % (dateTime, nodesString), button=["Accept"], defaultButton="Accept")
# select the custom node last
cmds.select(dynChain.mNode)
else:
cmds.confirmDialog(messageAlign="left", title="lpDynamicChains", message="Log:\n" + log, button=["Accept"], defaultButton="Accept")
示例2: run
def run(parent):
"""requires amTinyTools"""
try:
import amTinyTools
amTinyTools.Menu.menuSelect(parent)
except ImportError:
cmds.confirmDialog(m="this module requires amTinyTools")
示例3: checkout
def checkout(self):
curfilepath = cmd.file(query=True, sceneName=True)
if not curfilepath == '':
cmd.file(save=True, force=True)
toCheckout = self.get_asset_path()
try:
destpath = amu.checkout(toCheckout, True)
except Exception as e:
print str(e)
if not amu.checkedOutByMe(toCheckout):
cmd.confirmDialog( title = 'Can Not Checkout'
, message = str(e)
, button = ['Ok']
, defaultButton = 'Ok'
, cancelButton = 'Ok'
, dismissString = 'Ok')
return
else:
destpath = amu.getCheckoutDest(toCheckout)
toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb')
# open the file
if os.path.exists(toOpen):
cmd.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
else:
# create new file
cmd.file(force=True, new=True)
cmd.file(rename=toOpen)
cmd.file(save=True, force=True)
self.close_dialog()
示例4: 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....')
示例5: getSelection
def getSelection(self):
rootNodes = cmds.ls(sl=True, type='transform')
if rootNodes is None or len(rootNodes) < 1:
cmds.confirmDialog(t='Error', b=['OK'],
m='Please select one or more transform nodes.')
return None
else: return rootNodes
示例6: mkIngestionDir
def mkIngestionDir(source,type):
mkFile = source
filename =source.split("/")
filename = filename[-1]
mkSource =source.split("/")
mkSource = mkSource[-1]
mkSource = mkSource.replace( type, "" )
mkFolder =source.split("/")
mkFolder.pop(-1)
mkFolder = "/".join(mkFolder)
mkFolder=mkFolder+"/"+mkSource
if os.path.exists( mkFolder ) == False:
os.makedirs( mkFolder )
copycmd = 'sysFile -copy'+' '+'"'+mkFolder+'/'+ filename +'"'+' ' + '"'+ mkFile+'"'+';'
mel.eval (copycmd)
dst = "Q:/Tools/Nearline/ingestion/3dModels"
delcmd = 'sysFile -delete'+' "'+mkFile+'";'
mel.eval (delcmd)
createdirCmd = 'sysFile -makeDir'+' '+'"'+dst+'/' +mkSource+'/"'
mel.eval(createdirCmd)
cpyDepotCmd = 'sysFile -mov'+' '+'"'+dst+'/' +mkSource+'/'+filename +'"'+' ' + '"'+mkFolder+'/'+ filename +'"'+';'
mel.eval (cpyDepotCmd)
print "copied "+filename+" to depot"
removeEmptydir = 'sysFile -removeEmptyDir'+' '+'"'+mkFolder+'/";'
mel.eval (removeEmptydir)
cmds.confirmDialog(m=filename+" ready for upload", cb = "cancel")
return mkFolder
示例7: exportRig
def exportRig(self):
""" will export SH and Geo found in the geo folder """
# rig and geo should not be referenced
# find SH, delete constraints, parent to world
# find geo folder parent to world
# select SH and geo folder and export as fbx to fbx folder
pymelLogger.debug( 'Starting rig export' )
export = 0
for rig in self.rootList:
if cmds.objExists(rig):
# check if geo folder also exists
if cmds.objExists(self.geo):
self._delConstraints(rig)
cmds.parent(rig, w=1)
cmds.parent(self.geo, w=1)
cmds.select(rig,self.geo, r=1)
#print rig, self.geo
if self._fbxExport( 2 ):
cmds.confirmDialog(m='FBX Rig Exported', button='Ok')
pymelLogger.debug( 'Finished rig export' )
export = 1
break
else:
pymelLogger.error( 'No geo folder has been found' )
if export == 0 : pymelLogger.error( 'No Rig Exported. Note: Referenced Rigs Will Not Export' )
示例8: cacheFluidsToCTemp
def cacheFluidsToCTemp():
if cmds.objExists(CONST.FOAM_FLUID_SHAPENODE) and cmds.objExists(CONST.WAKE_FLUID_SHAPENODE):
## Get default non-cached wake and foam
fluidsToCache = []
for cache in [CONST.FOAM_FLUID_SHAPENODE, CONST.WAKE_FLUID_SHAPENODE]:
fluidConnection = cmds.listConnections(cache, type = 'cacheFile') or cmds.listConnections(cache, type = 'cacheBlend')
if fluidConnection:
if cmds.nodeType(fluidConnection[0]) == 'cacheFile' or cmds.nodeType(fluidConnection[0]) == 'cacheBlend':
cmds.confirmDialog(title = 'CACHE FLUIDS', message = 'Cache already exist for "%s". You should cleanup your caches if you want to re-cache a newer one!' % cache, button = 'OK')
else:
fluidsToCache.append(cache)
else:
fluidsToCache.append(cache)
## Cache em fluids at one go to save time
if fluidsToCache:
cachePath = _getPathFromSceneName()
if cachePath:
if os.path.exists(cachePath):
_cacheWake(cachepath = cachePath, fluids = fluidsToCache)
## Set time to min
[cmds.currentTime( cmds.playbackOptions(q = True, min = True) ) for x in range(2)]
else:
cmds.confirmDialog(title = 'CACHE FLUIDS', message = 'Both "%s" and "%s" fluids don\'t exist in your scene!' % (CONST.FOAM_FLUID_SHAPENODE, CONST.WAKE_FLUID_SHAPENODE), button = 'OK')
示例9: GetGroupName
def GetGroupName(self):
#Check to see if the name is saved with the file
if cmds.objExists("CMSettings"):
ScenePrepClass.GroupName = cmds.getAttr("CMSettings.ModelName")
if cmds.objExists(ScenePrepClass.GroupName):
print "Group name from save"
return 1
#Check to see if the model is already grouped then use that name#
if self.SelectedObjectsAreGrouped() != "":
if cmds.textField("NameTextField",query = True, text = True) != "":
#Rename the group if a name has been provided
cmds.rename(ScenePrepClass.GroupName, cmds.textField("NameTextField",query = True, text = True))
#Replace the name in cursel
for x in range(len(ScenePrepClass.Cursel)):
if ScenePrepClass.Cursel[x] == ScenePrepClass.GroupName:
ScenePrepClass.Cursel[x] = cmds.textField("NameTextField",query = True, text = True)
#
ScenePrepClass.GroupName = cmds.textField("NameTextField",query = True, text = True)
print "Group name from model"
return 1
#otherwise check the textfield
if cmds.textField("NameTextField",query = True, text = True) != "":
ScenePrepClass.GroupName = cmds.textField("NameTextField",query = True, text = True)
print "Group name from field"
if ScenePrepClass.GroupName == "":
cmds.confirmDialog(m = "Please enter a name for the model")
return 0
示例10: runTestCases
def runTestCases( testCases=TEST_CASES ):
thisPath = Path( __file__ ).up()
testResults = TestResult()
for ATestCase in testCases:
testCase = ATestCase()
testCase.run( testResults )
#force a new scene
cmd.file( new=True, f=True )
OK = 'Ok'
BUTTONS = (OK,)
if testResults.errors:
print '------------- THE FOLLOWING ERRORS OCCURRED -------------'
for error in testResults.errors:
print error[0]
print error[1]
print '--------------------------'
cmd.confirmDialog( t='TEST ERRORS OCCURRED!', m='Errors occurred running the tests - see the script editor for details!', b=BUTTONS, db=OK )
else:
print '------------- %d TESTS WERE RUN SUCCESSFULLY -------------' % len( testCases )
cmd.confirmDialog( t='SUCCESS!', m='All tests were successful!', b=BUTTONS, db=OK )
return testResults
示例11: creatStereo
def creatStereo():
camL = mc.ls(sl=1)
if camL == []:
mc.confirmDialog(title="Missing", message="Please select a camera!", button=["Ok"])
return
cam = camL[0]
camShape = mc.listRelatives(cam, s=1)[0]
FL = mc.camera(cam, q=1, fl=1)
NCP = mc.camera(cam, q=1, ncp=1)
FCP = mc.camera(cam, q=1, fcp=1)
cam3d = maya.app.stereo.stereoCameraRig.createStereoCameraRig()
mc.parent(cam3d[0], cam)
mc.setAttr(cam3d[0] + ".translate", 0, 0, 0, lock=1)
mc.setAttr(cam3d[0] + ".rotate", 0, 0, 0, lock=1)
mc.setAttr(cam3d[0] + ".scale", 1, 1, 1, lock=1)
cam3dShape = mc.listRelatives(cam3d[0], s=1)[0]
mc.connectControl("interaxialSleder", stereoShape + ".interaxialSeparation")
mc.connectControl("zeroSleder", stereoShape + ".zeroParallax")
mc.setAttr(cam3dShape + ".focalLength", FL)
mc.setAttr(cam3dShape + ".nearClipPlane", NCP)
mc.setAttr(cam3dShape + ".farClipPlane", FCP)
mc.setAttr(cam3dShape + ".zeroParallaxPlane", 1)
mc.setAttr(cam3dShape + ".safeViewingVolume", 1)
for i in cam3d:
mc.rename(i, cam + "_" + i)
camListStereo = mc.ls(type="stereoRigTransform")
if camListStereo == []:
mc.floatSliderGrp(interaxialSleder, e=1, enable=False)
mc.floatSliderGrp(zeroSleder, e=1, enable=False)
else:
stereoShape = mc.listRelatives(camListStereo[0], s=1)[0]
mc.floatSliderGrp(interaxialSleder, e=1, enable=True)
mc.floatSliderGrp(zeroSleder, e=1, enable=True)
mc.connectControl(interaxialSleder, cam3dShape + ".interaxialSeparation")
mc.connectControl(zeroSleder, cam3dShape + ".zeroParallax")
示例12: Pose_rtn
def Pose_rtn(name,*args):
lst=mc.ls(sl=1)
if lst==[]:
mc.confirmDialog (title='About' ,message= 'Nothing is selected',ma='center', button=['OK'] ,defaultButton='Yes')
else:
files=open(name,'r')
nextLine=files.readline()
sel_obj = mc.ls(sl=1)
char = sel_obj[0].split(':')
while (len( nextLine ) > 0 ):
splitter= nextLine.split(' ')
if splitter[0]=='obj':
obj_name= splitter[1].strip()
else:
attr = splitter[0]
value= splitter[1].strip()
if len(char)==1:
added=char[0]+ "." + attr
else:
added= (char[0] + ":" + obj_name + "." + attr)
setA = "mc.setAttr('"+added+"',"+ value+')'
try:
eval(setA)
except RuntimeError:
pass
nextLine=files.readline()
files.close()
print "Pose changed"
示例13: deletetab
def deletetab(*args):
alltabs = mc.tabLayout ('tabs',q=1,st=1)
chktabs = mc.tabLayout ('Animation',q=1,st=1)
chktabs1= mc.tabLayout ('Poses',q=1,st=1)
if alltabs == 'Animation':
seltab = mc.tabLayout('Animation',q=1,st=1)
mc.deleteUI(seltab)
Del_tab=savepathini+'Savepose/Animation/'+seltab
Del1_in=Del_tab+'/'
list_in=mc.getFileList(fld=Del1_in)
for i in range(len(list_in)):
mc.sysFile(Del1_in+'/'+list_in[i],delete=1)
mc.sysFile(Del_tab,red=1)
if chktabs=='':
mc.confirmDialog (title='Error',message='No tabs to delete', button='OK',defaultButton='Yes')
# else :
# return
else :
seltab = mc.tabLayout('Poses',q=1,st=1)
mc.deleteUI(seltab)
Del_tab=savepathini+'Savepose/Poses/'+seltab
Del1_in=Del_tab+'/'
list_in=mc.getFileList(fld=Del1_in)
for i in range(len(list_in)):
mc.sysFile(Del1_in+'/'+list_in[i],delete=1)
mc.sysFile(Del_tab,red=1)
if chktabs1=='':
mc.confirmDialog (title='Error',message='No tabs to delete', button='OK',defaultButton='Yes')
else :
return
示例14: Newtab
def Newtab(*args):
sel_tab = mc.shelfTabLayout('tabs',q=1,st=1)
crnt_tab= mc.shelfTabLayout(sel_tab,q=1,ca=1)
Newtab = mc.promptDialog(
title='Create New Tab',
message='New Tab Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if Newtab == 'OK':
n_text = mc.promptDialog(query=True, text=True)
if n_text == '':
mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is not valid', button=['OK'] ,defaultButton='Yes')
else:
if crnt_tab:
for each in crnt_tab:
if each == n_text:
mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is already exists', button=['OK'] ,defaultButton='Yes')
return
#else:
if sel_tab == 'Animation':
Nw_tab=savepathini+'Savepose/Animation/'+n_text+'/'
mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Animation)
mc.sysFile(Nw_tab, makeDir=True )
else:
mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Poses)
Nw_tab=savepathini+'Savepose/Poses/'+n_text+'/'
mc.sysFile(Nw_tab, makeDir=True )
mc.shelfTabLayout(sel_tab,e=1,st=n_text)
示例15: drawError
def drawError(self,errormsg=""):
""" Draw a error message dialog
@type errormsg: string
@param errormsg: the messag to display
"""
cmds.confirmDialog(title='ERROR:', message=errormsg, button=['OK'],
defaultButton='OK')