本文整理汇总了Python中maya.cmds.fileDialog2函数的典型用法代码示例。如果您正苦于以下问题:Python fileDialog2函数的具体用法?Python fileDialog2怎么用?Python fileDialog2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fileDialog2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findReference
def findReference( path="", expression="", force=False, dialog=False ):
"""
List similar files for current file .
"""
result = ""
if os.path.isfile( path ):
filename = path.split( "/" )
directory = "/".join( filename[0:-1] ) + "/"
filename = filename[-1].split( "." )[0]
files = os.listdir( directory )
expression = re.compile( expression, re.IGNORECASE )
if expression.findall( filename ):
ignore = True
else:
ignore = False
for i in range( 0, len( files )):
if re.findall( ".ma|.mb", files[i] ):
mfiletemp = files[i].split( "/" )[-1].split( "." )[0]
if filename != mfiletemp:
if ignore is True:
if mfiletemp == expression.sub( "", filename ):
return os.path.join( directory, files[i] )
else:
if filename == expression.sub( "", mfiletemp ):
return os.path.join( directory, files[i] )
if result != "" and force is True and dialog is False:
result = cmds.fileDialog2( caption="Reference", fileFilter="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb)", startingDirectory=directory, fileMode=1 )
elif dialog is True:
result = cmds.fileDialog2( caption="Reference", fileFilter="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb)", startingDirectory=directory, fileMode=1 )
if result:
result = result[-1]
return result
示例2: __init__
def __init__(self) :
# create a promptDialog for the base group name of our mesh this will help to
# avoid name conflicts, may be good to modify this at some stage to check if mesh
# exists and prompt to replace data / key
result = cmds.promptDialog(
title='Name',
message='Enter Name for import',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
# if ok was pressed lets process the data
if result == 'OK':
# first we get the text entered by the user
self.m_text = cmds.promptDialog(query=True, text=True)
# now get the obj file to import
self.m_objFileName=cmds.fileDialog2(caption="Please select obj file to import",fileFilter="*.obj", fm=1)
cmds.file(self.m_objFileName,i=True,type="OBJ",ns=self.m_text)
# now the xml file
basicFilter = "*.xml"
self.m_pointBakeFile=cmds.fileDialog2(caption="Please select xml file to import",fileFilter=basicFilter, fm=1)
# select the object imported
print self.m_pointBakeFile
cmds.select("%s:Mesh"%(self.m_text))
# and pass control back to the parser
parser = xml.sax.make_parser()
parser.setContentHandler(ParseHandler("%s:Mesh"%(self.m_text)))
parser.parse(open(str(self.m_pointBakeFile[0]),"r"))
示例3: browse
def browse(folder,*args):
if folder=='renderFolder':
mc.textField(str(folder),edit=1,text=mc.fileDialog2(ds=2,dir=os.path.join(mc.workspace(q=1,rd=1),'scenes'),fm=3,okc="Set",cc="Cancel")[0].split('/')[-1])
else:
mc.textField(str(folder),edit=1,text=mc.fileDialog2(ds=2,dir=os.path.join(mc.workspace(q=1,rd=1),'scenes'),fm=3,okc="Set",cc="Cancel")[0])
commitUI()
UI()
示例4: get_open_file_name
def get_open_file_name(file_filter=None):
if file_filter:
files = mc.fileDialog2(fileFilter='.' + file_filter, fileMode=1)
else:
files = mc.fileDialog2(fileMode=1)
if files:
return files[0]
else:
return None
示例5: getSaveFileName
def getSaveFileName(filter = None):
if filter:
files = mc.fileDialog2(fileFilter = '.' + filter, fileMode = 0)
else:
files = mc.fileDialog2(fileMode = 0)
if files:
return files[0]
else:
return None
示例6: Dialog
def Dialog(mode):
singleFilter = "SKL Files (*.skl)"
if mode == "export":
path = cmds.fileDialog2(ff=singleFilter, fm=0, okc = "OK")[0].rpartition(".")[0]
if mode == "import":
path = cmds.fileDialog2(ff=singleFilter, fm=1, okc = "OK")[0].rpartition(".")[0]
return path + ".skl"
示例7: ExportData
def ExportData(data):
multipleFilters = "JSON Files (*.json)"
f = cmds.fileDialog2(fileMode=0, fileFilter=multipleFilters)
if f:
f = open(f[0], 'w')
json.dump(data, f)
f.close()
示例8: importParticleFile
def importParticleFile() :
basicFilter = "*.out"
fileName=cmds.fileDialog2(caption="Please select file to import",fileFilter=basicFilter, fm=1)
if fileName[0] !=None :
file=open(str(fileName[0]))
frame=0
numParticles=0
#set to frame 0
animControl=OMA.MAnimControl()
animControl.setCurrentTime(OM.MTime(frame))
for line in file :
line=line.split(" ")
if line[0]=="NumParticles" :
numParticles=int(line[1])
elif line[0]=="Frame" :
frame=int(line[1])
animControl.setCurrentTime(OM.MTime(frame))
else :
name=line[0]
x=float(line[1])
y=float(line[2])
z=float(line[3])
if frame==0 :
#we need to create our initial locators
createLocator(name,x,y,z)
else :
moveLocator(name,x,y,z)
示例9: shotReferenceTool_getTextFieldInfo
def shotReferenceTool_getTextFieldInfo(fileFilter, fileMode, textField, *args):
filePath = cmds.fileDialog2(fileMode= fileMode, dialogStyle=2, fileFilter = fileFilter)[0]
filePath = str(filePath)
cmds.textField(textField, edit = True, text = filePath)
return filePath
示例10: confirmSave
def confirmSave():
base = studioBase.StudioSQL()
result = cmds.confirmDialog( title='File not saved', message='Save file?', button=['Save', 'Dont save', 'Cancel'], defaultButton='Save', cancelButton='Cancel')
# --- Save ------------------------------------------------------
if result == 'Save':
fileName = cmds.file(q=True, sceneName=True)
if not fileName:
fileName = cmds.fileDialog2(ds=1, fileMode=0, caption="Save file", fileFilter='Maya ASCII (*.ma);;Maya Binary (*.mb)')
if fileName:
fileName = fileName[0]
cmds.file(rename=fileName)
else:
return False
base.setAction('save', fileName)
if fileName.split('.')[-1] == 'ma':
cmds.file(save=True, type='mayaAscii')
else:
cmds.file(save=True, type='mayaBinary')
return True
# --- Dont save -------------------------------------------------
elif result == 'Dont save':
return True
# --- Cancel ----------------------------------------------------
else:
return False
示例11: browseDirectoryPath
def browseDirectoryPath(self, *args):
basicFilter = "*All(*.*);;tif(*.tif);;jpg(*.jpg);;exr(*.exr);;tx(*.tx)"
self.returnPath = cmds.fileDialog2(
fileFilter=basicFilter,
ds=2,
startingDirectory=self.homeDir)[0]
cmds.textField(self.uvImagePath, e=True, text=self.returnPath)
示例12: select_file
def select_file(self):
""" Maya Open Dialog to select file texture """
self.open_dialog_visible = True
if MTTSettings.value('browserFirstStart'):
image_dir = cmds.optionVar(query='MTT_browserStartFolder')
else:
image_dir = cmds.workspace(query=True,
rootDirectory=True) + cmds.workspace(
fileRuleEntry='sourceImages')
MTTSettings.set_value('browserFirstStart', True)
file_path = cmds.fileDialog2(fileMode=1, startingDirectory=image_dir,
caption='Select a texture',
okCaption='Select')
if file_path:
new_path = file_path[0]
cmds.optionVar(
sv=['MTT_browserStartFolder', os.path.dirname(new_path)])
if MTTSettings.value('forceRelativePath'):
new_path = convert_to_relative_path(new_path)
# relative_path = workspace(projectPath=new_path)
# if relative_path != new_path:
# new_path = '/%s' % relative_path
self.line_edit.setText(new_path)
self.open_dialog_visible = False
self.close()
self.editingFinished.emit()
cmds.showWindow(WINDOW_NAME)
示例13: onAddNewImage
def onAddNewImage(self, *args):
imageFilter = "All Files(*.*)"
filePaths = cmds.fileDialog2(dialogStyle = 2, fileMode=1, fileFilter=imageFilter)
if filePaths:
newImageElement = self.createImageElement(filePaths[0])
if newImageElement:
self.updateScrollLayout(newImageElement)
示例14: _open
def _open(self):
"""open marking menu"""
self._file_read = cmds.fileDialog2(fm=1, ff='menu_*.mel', dir=cmds.internalVar(umm=True))[0]
self.ui.list_items.clear()
self.ui.list_items.setCurrentRow(-1)
self._data = []
self._mel_block = open(self._file_read).readlines()
i = 0
while i < len(self._mel_block):
if 'menuItem' in self._mel_block[i]:
i += 1
item = {"label": "", "command": [-1, ""], "language": [-1, "mel"], "icon": ""}
include = True
while '-' in self._mel_block[i]:
if '-label ' in self._mel_block[i]:
item["label"] = re.match('(.*)-label "(.*)"(.*)', self._mel_block[i]).group(2)
elif '-command ' in self._mel_block[i]:
item["command"] = [i, re.match('(.*)-command "(.*)"(.*)', self._mel_block[i]).group(2)]
elif '-sourceType ' in self._mel_block[i]:
item["language"] = [i, re.match('(.*)-sourceType "(.*)"(.*)', self._mel_block[i]).group(2)]
elif '-image ' in self._mel_block[i]:
item["icon"] = re.match('(.*)-image "(.*)"(.*)', self._mel_block[i]).group(2)
elif '-subMenu 1' in self._mel_block[i] or '-optionBox 1' in self._mel_block[i]:
include = False
i += 1
if include:
self._data.append(item)
self.ui.list_items.addItem(item["label"])
else:
i += 1
示例15: check_editor_preferences
def check_editor_preferences():
# get preference values of external app path
photo_dir = cmds.optionVar(exists='PhotoshopDir')
image_dir = cmds.optionVar(exists='EditImageDir')
# if there is no external app, request for an app path
if not photo_dir and not image_dir:
pref_warn = QMessageBox()
pref_warn.setWindowTitle(WINDOW_TITLE)
pref_warn.setIcon(QMessageBox.Warning)
pref_warn.setText(
'<b>Applications for Editing Image Files</b> '
'is not set in your preferences.<br>'
'Maya needs it to send image in the right Image Editor '
'instead of file system association.')
pref_warn.setInformativeText('Do you want to select an application ?')
pref_warn.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
pref_warn.setDefaultButton(QMessageBox.Yes)
pref_warn.setEscapeButton(QMessageBox.Cancel)
ret = pref_warn.exec_()
if ret == QMessageBox.Yes:
app_path = cmds.fileDialog2(
fileFilter='Image editor application (*.exe)',
caption='Select image editor application',
startingDirectory=os.path.expandvars('%ProgramFiles%'),
fileMode=1)
if app_path is not None:
cmds.optionVar(sv=('PhotoshopDir', app_path[0]))
cmds.optionVar(sv=('EditImageDir', app_path[0]))