本文整理汇总了Python中maya.cmds.fileDialog2函数的典型用法代码示例。如果您正苦于以下问题:Python fileDialog2函数的具体用法?Python fileDialog2怎么用?Python fileDialog2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fileDialog2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:k0k0c,项目名称:scripts,代码行数:32,代码来源:ml_reference.py
示例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"))
开发者ID:NCCA,项目名称:PointBake,代码行数:31,代码来源:NCCAPointBakeMayaImport.py
示例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()
开发者ID:RobRuckus,项目名称:rcTools,代码行数:7,代码来源:rcFileManager.py
示例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
开发者ID:akoon,项目名称:OldPipeline,代码行数:9,代码来源:utility.py
示例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
开发者ID:akoon,项目名称:OldPipeline,代码行数:9,代码来源:render.py
示例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"
开发者ID:MercurialForge,项目名称:obj-plus-plus,代码行数:10,代码来源:OBJ++.py
示例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()
开发者ID:Bumpybox,项目名称:Tapp,代码行数:7,代码来源:utils.py
示例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)
开发者ID:NCCA,项目名称:SimulationExports,代码行数:30,代码来源:LoadParticlesMaya.py
示例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
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:7,代码来源:je_shotReferenceTool.py
示例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
开发者ID:kuzubov,项目名称:maya_python_scripts,代码行数:30,代码来源:mayaMainBtns.py
示例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)
开发者ID:minoue,项目名称:miUV,代码行数:7,代码来源:miUV.py
示例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)
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:30,代码来源:mttDelegate.py
示例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)
开发者ID:Firebolt93q,项目名称:maya-tools,代码行数:7,代码来源:imageframeScrollview.py
示例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
开发者ID:DavideAlidosi,项目名称:May9,代码行数:31,代码来源:LanguageChange.py
示例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]))
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:31,代码来源:mttCmd.py
示例16: browseButton
def browseButton( self, *args ):
#pops up search window
filterType = "*.xyz"
self.widgets[ "browseField" ] = cmds.fileDialog2( dialogStyle=2, caption='Load LIDAR', fileMode=1, fileFilter=filterType )
cmds.textField( self.widgets[ "lidarPathField" ], edit=True, text=self.widgets[ "browseField" ][0] )
开发者ID:jorge3186,项目名称:LIDARloader,代码行数:7,代码来源:LIDARloader.py
示例17: setDBPath
def setDBPath(self, *args):
fileFilters = "Database (*.db *.sqlite) (*.db *.sqlite)"
path = cmds.fileDialog2(fileMode=1, caption="Open .db File", dialogStyle=2, okCaption="Open", startingDirectory=self.basedir, fileFilter=fileFilters)
if path == None:
return
cmds.textFieldButtonGrp("tfbDBPath", e=True, tx=path[0])
开发者ID:Quazo,项目名称:breakingpoint,代码行数:7,代码来源:jf_shaderLinker.py
示例18: setShaderPath
def setShaderPath(self, *args):
fileFilters = "Maya File(*.mb *.ma)"
path = cmds.fileDialog2(fileMode=1, caption="Set Shader Path", dialogStyle=2, okCaption="Save", startingDirectory=self.basedir, fileFilter=fileFilters)
if path == None:
return
cmds.textFieldButtonGrp("tfbShaderPath", e=True, tx=path[0])
开发者ID:Quazo,项目名称:breakingpoint,代码行数:7,代码来源:jf_shaderLinker.py
示例19: loadDirectoryPath
def loadDirectoryPath(textField,caption='Load Directory',startDir=None):
'''
Select a file path to load into a specified textField.
@param textField: TextField UI object to load file path to
@type textField: str
@param caption: File selection UI caption string
@type caption: str
@param startDir: Directory to start browsing from. In None, use the default or last selected directory.
@type startDir: str
'''
# Get File Path
dirPath = mc.fileDialog2( dialogStyle=2,
fileMode=3,
caption=caption,
okCaption='Load',
startingDirectory=startDir )
# Check File Path
if not dirPath:
print('Invalid directory path!')
return
# Load File Path to TextField
if mc.textField(textField,q=True,ex=True):
mc.textField(textField,e=True,text=dirPath[0])
elif mc.textFieldGrp(textField,q=True,ex=True):
mc.textFieldGrp(textField,e=True,text=dirPath[0])
elif mc.textFieldButtonGrp(textField,q=True,ex=True):
mc.textFieldButtonGrp(textField,e=True,text=dirPath[0])
else:
print('UI element "'+textField+'" is of type "'+mc.objectTypeUI(textField)+'"! Expected textField, textFieldGrp or textFieldButtonGrp.')
return
# Return Result
return dirPath[0]
开发者ID:auqeyjf,项目名称:glTools,代码行数:35,代码来源:utils.py
示例20: savefolder
def savefolder(savepathini):
newpath=mc.fileDialog2(ds = 1, fm = 3)
if newpath:
chkpath= newpath[0]+'/'
counts=mc.getFileList (folder=chkpath)
nc=counts.count('SavePose')
if not nc:
cofirm_but=mc.confirmDialog( title='Confirm', message='Do u want to create a new library in '+newpath[0]+ ' ??', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
if cofirm_but=='Yes':
getMnuItms=mc.menu('chgFld',q=1,ia=1)
if len(getMnuItms) >= 7:
mc.deleteUI(getMnuItms[3],mi=1)
getMnuItms=mc.menu('chgFld',q=1,ia=1)
getItmLab=[]
for each in getMnuItms:
lab=mc.menuItem(each,q=1,l=1)
getItmLab.append(lab)
if newpath:
if newpath[0] not in getItmLab:
mc.menuItem(label=newpath[0],p='chgFld',c=partial(changepath,newpath))
savepathini=newpath[0]
else:
return
else:
savepathini=newpath[0]
else:
return
Refresh_UI(savepathini)
temp_path(savepathini)
开发者ID:sid2364,项目名称:Maya_Python,代码行数:29,代码来源:SR_AnimPoseLib.py
注:本文中的maya.cmds.fileDialog2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论