本文整理汇总了Python中maya.cmds.fileDialog函数的典型用法代码示例。如果您正苦于以下问题:Python fileDialog函数的具体用法?Python fileDialog怎么用?Python fileDialog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fileDialog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getExportFilePathUI
def getExportFilePathUI():
mode = cmds.radioButtonGrp( 'em_modeRadio',q=1, select=1)
if mode ==1:
filePath = cmds.fileDialog(mode=1, dm=('*.obj') )
if mode ==2:
filePath = cmds.fileDialog(mode=1, dm=('*.mdd') )
if mode ==3:
filePath = cmds.fileDialog(mode=1, dm=('*.geo') )
filePath = pathToWindows(filePath)
cmds.textFieldButtonGrp('em_fileName',e=1, text=filePath)
return filePath
示例2: saveToLocal
def saveToLocal(showWarning=True):
episod, shot = getEpiAndShotFromUI()
if not shot: return
if showWarning:
warnMsg = 'SceneName from window doesnt match with opened scene\'s name.\nSceneName will be taken from window by default.\nDo you want to continue?'
if not filenamesMatch(episod, shot):
rslt = mc.confirmDialog(t='Warning', m=warnMsg, b=['Continue', 'Cancel'], db='Continue', cb='Cancel', ds='Cancel')
if rslt == 'Cancel':
return
expr = '^%s_%s%ssh%s_%s_.*[.]ma' % (util.projShort, util.epOrSeq, episod, shot, util.deptDic['short'])
dfltName = '%sv00.ma' % expr[1:-7]
pathToSave = mc.fileDialog(m=1, dm='*.ma', dfn=dfltName)
if pathToSave:
filename = pathToSave.split('/')[-1]
if re.search(expr, filename): # Check if filename matches the required format
util.correctFrames(episod, shot)
#joj - March 9
Utils.switchToProxy()
mc.file(rn=pathToSave)
mc.file(s=True, typ='mayaAscii')
mc.confirmDialog(t='Success', m='Saved as:\n%s' % pathToSave, b='THANX')
else:
mc.confirmDialog(t='Error', m='SceneName format is incorrect', b='SORRY')
saveToLocal(False)
示例3: saveBtnCmd
def saveBtnCmd(self, *args):
"""Called when the Save Light Setup button is pressed, saves data to file"""
print("Save Menu Btn has been clicked")
cmds.select("Three_Point_Lights")
rootNodes = self.getSelection()
if rootNodes is None:
try:
rootNodes = self.getSelection()
except:
return
#defaults to home directory for the moment
filePath = ''
# Maya 2011 and newer use fileDialog2
try:
filePath = cmds.fileDialog2(
ff=self.fileFilter, fileMode=0
)
# BUG: Maya 2008 and older may, on some versions of OS X, return the
# path with no separator between the directory and file names:
# e.g., /users/adam/Desktopuntitled.pse
except:
filePath = cmds.fileDialog(
dm='*.%s' % kLightFileExtension, mode=1
)
# early out of the dialog was canceled
if filePath is None or len(filePath) < 1: return
if isinstance(filePath, list): filePath = filePath[0]
exportSetup(filePath, cmds.ls(sl=True, type='transform'))
示例4: _saveTab
def _saveTab(self):
'''
The name of the tab
The frames included
the attributes for each frame
'''
# Prompt where to save the file.
# pack data
currTab = cmds.tabLayout( self.mainTab, q=True, selectTab=True)
tabIndex = cmds.tabLayout( self.mainTab, q=True, selectTabIndex=True) - 1 # tab index are 1 based.
tabLabels = cmds.tabLayout( self.mainTab, q=True, tl=True )
tabName = tabLabels[tabIndex]
frameNames = []
frames = {}
for frameInfo in self.tabs[self.tabNames[tabIndex]]:
frameNames.append([frameInfo.frameName, frameInfo.mainLayout])
frames[frameInfo.mainLayout] = frameInfo.attrs
path = cmds.fileDialog(mode=1)
if(path):
fileInfo = open( path, "w" )
pickle.dump( tabName, fileInfo )
pickle.dump( frameNames, fileInfo )
pickle.dump( frames, fileInfo )
fileInfo.close()
else:
print("Save Cancelled.")
示例5: writeSelAttrFile
def writeSelAttrFile():
"""
Writes the selected attributes from the textScrollList to a file.
"""
# Let the user choose where the files is being saved to.
# Starting point will be the maya folder.
mayaFolder = cmds.internalVar(userAppDir=True)
# File Dialog
# sba will be the file extension.
filePath = cmds.fileDialog(mode=1, directoryMask=mayaFolder + "*.sba")
print("Choosen file: " + filePath)
# Gather the attributes from the textScrollList
selectedTSL = cmds.textScrollList("sbaKeyTSL", q=True, si=True)
# Open File
attrFile = open(filePath, "w") # Will overwrite the file if it allready exists!
# Loop through one element at a time writing it to a file.
for item in selectedTSL:
attrFile.write(item + "\n")
# Close File
attrFile.close()
示例6: readAttr
def readAttr():
"""
Read attributes from a chosen file.
"""
# Get information from file
# Starting at the maya folder and limiting to extension .sba
mayaFolder = cmds.internalVar(userAppDir=True)
# File Dialog
# sba will be the file extension.
filePath = cmds.fileDialog(mode=0, directoryMask=mayaFolder + "*.sba")
print("Choosen file: " + filePath)
# Open File
attrFile = open(filePath, "r") # Will overwrite the file if it allready exists!
attrs = attrFile.readlines()
# Close File
attrFile.close()
# loop through file content adding to the textScrollList
for attr in attrs:
# Check to see if the attribute allready exists in the textScrollList
attr = attr.rstrip()
# all the current tsl items
allItemsTSL = cmds.textScrollList("sbaKeyTSL", q=True, allItems=True)
if allItemsTSL and (attr in allItemsTSL):
print(attr + " all ready exists in the list.")
else:
cmds.textScrollList("sbaKeyTSL", edit=True, append=attr)
示例7: importABCasVRMesh
def importABCasVRMesh():
pathPick = cmds.fileDialog()
path = os.path.split(pathPick)[1]
name = path.split(".")[0]
# Export alembic as VRMesh
mel.eval('vrayCreateProxyExisting("%s", "geo/%s")' % (name, path))
示例8: loadShapes
def loadShapes(cls):
path = cmds.fileDialog(mode=0, directoryMask="*.shapes")
success = "Successfuly loaded shape {0} for {1}."
err = "{0} does not exist, skipping."
the_file = open(path, 'rb')
shapesData = pickle.load(the_file)
print shapesData
for obj in shapesData.keys():
if not cmds.objExists(obj):
print err.format(obj)
continue
# parent does exist
# delete shapes from obj
cmds.delete(cmds.listRelatives(obj, s=True, type="nurbsCurve"))
# initialize object as curve
con = cls(name='L_' + obj)
con.name = obj
for shape in shapesData[obj].keys():
pos = shapesData[obj][shape]['positions']
dg = shapesData[obj][shape]['degree']
knots = shapesData[obj][shape]['knots']
color = shapesData[obj][shape]['color']
period = shapesData[obj][shape]['period']
p = True if period > 0 else False
con.color = color
curve = cmds.curve(degree=dg, point=pos, knot=knots, per=p)
con.get_shape_from(curve, destroy=True, replace=False)
print success.format(shape, obj)
示例9: _loadTab
def _loadTab(self):
print("Load Tab")
path = cmds.fileDialog( mode=0)
# load
if( path ):
# Reading fileInfo
fileInfo = open( path, "r" )
tabName = pickle.load( fileInfo )
frameNames = pickle.load( fileInfo )
frames = pickle.load( fileInfo )
fileInfo.close()
# Create Tab with tabname
tab = self._addTab( tabName )
for frame in frameNames:
# frame[0] the name of the frame
# frame[1] is the layoutName (this is done so the dictionary doesn't get overlap)
# frameGrp = self._addFrame( frame[0] )
newAttr = FrameGroup( tab , frame[0] )
self.tabs[self.tabNames[-1]].append( newAttr )
for attrItem in frames[frame[1]]:
if( cmds.objExists(attrItem) ):
newAttr.addAttr( attrItem )
'''
print(tabName)
print(frameNames)
print(frames)
'''
else:
print("Load Cancelled.")
示例10: importCurveShape
def importCurveShape(self):
filePath=mc.fileDialog(dm='*.cs',m=0)
if filePath:
readFile = open(filePath,'r')
ShapeData = pickle.load(readFile)
readFile.close()
self.setCurveShape(ShapeData)
示例11: loadImageDir
def loadImageDir(self,*args):
"""
opens dialog so user can browse to the overscan image.
This will not be neccessary once standard paths for the Tools shelf
and icons/images are in place.
"""
dir = cmds.fileDialog( directoryMask='*.png' )
cmds.textFieldButtonGrp(self.imageField,edit=True,text=dir)
示例12: openSceneButtonFunction
def openSceneButtonFunction(*args):
import os
global sceneFileName
global selectedFileName
selectedFileName=cmds.fileDialog()
cmds.launchImageEditor(vif=selectedFileName)
sceneFileName=os.path.basename(selectedFileName)
cmds.textField('sceneName', w=400, e=1, fi=sceneFileName)
示例13: fileSaveDialog
def fileSaveDialog(self, *args):
#!!! look into this
saveFileName = self.base.strip()
#self.downloadPath = tkFileDialog.asksaveasfile(mode='w', initialfile=str(saveFileName))
self.downloadPath = cmds.fileDialog(mode=1, defaultFileName=str(saveFileName))
示例14: read_PFtrack_3dPoint
def read_PFtrack_3dPoint():
basicFilter = '*.txt'
filename =cmds.fileDialog(dm=basicFilter,title='Open_pftrack_3dPoints_file')#'D:/suvey_points_0110.txt'
if not (filename==''):
result=read_pf3dpoints_asciifile(filename)
if len(result)>0:
spread_PF3dPoints(result)
示例15: exportCurveShape
def exportCurveShape(self):
filePath=mc.fileDialog(dm='*.cs',m=1)
if filePath:
if 'cs' != filePath.split('.')[-1]:
filePath += '.cs'
ShapeData = self.getCurveShape()
newFile = open(filePath,'w')
pickle.dump(ShapeData,newFile)
newFile.close()