def sourceFilesPath(self): cmds.fileBrowserDialog( m=4, fc=self.getSrcDir, ft="directory", an="Select the folder that contains the 'openpipeline' directory")
def relinkMissingMap(): if( len(_missMapPath)==0): cmds.confirmDialog( t="Warning", message= "No missing maps in lists!" , button = "OK" ); return; ## return the user defined path to the callback function "setMissMapPat" cmds.fileBrowserDialog( mode=4, dialogStyle = 2, fileCommand=setMissMapPath,\ actionName="Set new directory" );
def __init__(self, curPath=None): self.fileName = None self.fileType = None cmds.fileBrowserDialog(m=4, fc=self.getItems, ft='image', an='Import_Image', om='Import')
def saveScene(self, *args): #save_query_action queryColorSave=cmds.button('save', bgc=True, q=True) #save_action_function if queryColorSave[0]<0.4: cmds.fileBrowserDialog( m=4, fc=self.file_path, an='Choose folder to Save', om="Nein" ) else: cmds.warning("Please set a new File-Data")
def pickFolder(*args): ''' Brings up a file browser dialog. - For this script I wish to select a directory instead of a file. Two options need to be set to pick diectories. mode=4 & tm="folder" - The fileBrowserDialog needs to call a directory fc=tslLoader --> this is the directory an="Choose Directory --> Label on the Dialog ''' fileName = cmds.fileBrowserDialog( m=4, tm="folder", fc=tslLoader, an="Choose Directory" )
def pickFolder(): ''' Brings up a file browser dialog. - For this script I wish to select a directory instead of a file. Two options need to be set to pick diectories. mode=4 & tm="folder" - The fileBrowserDialog needs to call a directory fc=tslLoader --> this is the directory an="Choose Directory --> Label on the Dialog ''' fileName = cmds.fileBrowserDialog(m=4, tm="folder", fc=tslLoader, an="Choose Directory")
def browseForFile(actionName="Select", fileCommand=None, fileType=None, **kwargs): """ Open a window to browse for a file. Will use fileBrowserDialog if on windows, fileDialog if not. """ if fileCommand is None: def fileCommand(*args, **kwargs): pass if os.name == 'nt': exportFileName = cmds.fileBrowserDialog(fileCommand=fileCommand, actionName=actionName, fileType=fileType, **kwargs) else: exportFileName = cmds.fileDialog(title=actionName) fileCommand(exportFileName, fileType) return exportFileName
def selectImagePlane(self,btn=None): imgFilter ="All Image files (*.jpg *.gif *.png);;JPEG Image Files (*.jpg *.jpeg);;Gif Image Files (*.gif);;All Files (*.*)" try: if self.mayaVer>= 2011: chosenFile = cmds.fileDialog2(fm=1, ds=0, cap="Lets import Image",dir=self.txtfldpath(), ff=imgFilter ,okc="Select Image to Import", hfe=0) else: chosenFile = cmds.fileBrowserDialog( m=0, fc=self.importImage, ft=imgFilter, an='Select Image to Import', om='Import',ds=0 ) chosenFile = self.filename if chosenFile: #IF chosen file is not empty if (btn=='frntbtn'): cmds.textField('fronti', edit=1, text=chosenFile[0]) elif btn=='topbtn': cmds.textField( 'topi', edit=1, text=chosenFile[0]) elif btn=='sidebtn': cmds.textField( 'sidei', edit=1, text=chosenFile[0]) elif btn=='backbtn': cmds.textField('backi',edit=1,text=chosenFile[0]) else: print("nothing") except NameError as e: print(sys.exc_info()[0]), e
def DJB_BrowserWindow(filter_=None, caption_="Browse", fileMode_="directory"): multipleFilters = None filtersOld = None if filter_ == "Maya": multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb)" filtersOld = None elif filter_ == "Maya_FBX": multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;FBX (*.fbx);;All Files (*.*)" elif filter_ == "FBX": multipleFilters = "FBX (*.fbx);;All Files (*.*)" else: multipleFilters = "" window = None version = mel.eval("float $ver = `getApplicationVersionAsFloat`;") if version <= 2011.0: if fileMode_ == "directory": window = mayac.fileBrowserDialog(dialogStyle=2, windowTitle=caption_, fileType="directory") else: #new style dialog window if fileMode_ == "directory": window = mayac.fileDialog2(fileFilter=multipleFilters, dialogStyle=2, caption=caption_, fileMode=3, okCaption="Select") else: window = mayac.fileDialog2(fileFilter=multipleFilters, dialogStyle=2, caption=caption_, fileMode=4, okCaption="Select") if window: return window[0] else: return window
def jpmLH_setPathDialog(): cmds.fileBrowserDialog(m=4, fc=jpmLH_setPath, an='Set Layer Harvest Path')
def jpmLH_writeDialog(): cmds.fileBrowserDialog(m=1, fc=jpmLH_write, an='Save Layers')
def jpmLH_batchDialog(): cmds.fileBrowserDialog(m=0, fc=jpmLH_batch, an='Pick Batch File')
def setFolderBtn(self, *args): cmds.fileBrowserDialog(mode=4, fileCommand=self.linkFolder, actionName='Set Folder', operationMode='Reference')
def fl_addFiles(self, *args): cmds.fileBrowserDialog(m=0, fc=self.fl_addFilesHandler, an='Choose...', om='Import')
def bfs_saveBrowse(self, *args): cmds.fileBrowserDialog(m=4, fc=self.bfs_saveBrowseHandler, an='Select a folder...', om='Import')
def selectPath(self): try: cmds.fileBrowserDialog( m=4, fc=self.browseDir, ft='directory', an='Select directory', om='Select Directory' ) except RuntimeError: api.MGlobal.displayError( "please type in the path in textfield.")
''' Icon File Browser ''' import glob import maya.cmds as cmds cmds.fileBrowserDialog( m=4, fc=iconViewer, an='View Images', om='Import' ) def iconViewer(fileName, fileType): # print(fileName, fileType) iconPath = lambda type, path="" : os.path.join( fileName, path, "*.%s" %type ) iconType = "xpm" paths = glob.glob(iconPath( iconType )) print(iconPath(iconType), fileName, paths ) cmds.window( title="Icon Viewer", w=300, h=300 ) cmds.scrollLayout() cmds.rowColumnLayout( nc=10 ) for path in paths: pathPieces = os.path.split(path) cmds.symbolButton( i=path, c=(lambda x: punched(path, pathPieces[1]))) cmds.showWindow() def punched(path, icon): print("IconName: %s\nIconPath: %s" %(icon, path))
import os
def jpmAW_setPathDialog(): cmds.fileBrowserDialog(m=4, fc=jpmAW_setPath, an='Set Anim Writer Path')
def browseIt(): cmds.fileBrowserDialog( m=4, fc=dirPath, ft='directory', an='Choose Directory') return
def SetFolderBtnCmd(self, *args): cmds.fileBrowserDialog(mode=4, fc=self.relinkFolder, an='Set Folder', om='Reference')
def __init__(self, curPath=None): self.fileName = None self.fileType = None cmds.fileBrowserDialog( m=4, fc=self.getItems, ft='image', an='Import_Image', om='Import' )
def collectMap(): initialize(); _newMapPath = ""; ## return the user defined path to the callback function "transMapsToDict" cmds.fileBrowserDialog( mode=4, dialogStyle = 2, fileCommand=transMapsToDict,\ actionName="Select new path" );
def dirBrowseDialog(): cmds.fileBrowserDialog(fileCommand = getDirPath, mode = 4, actionName = 'Set')
''' Icon File Browser ''' import glob import maya.cmds as cmds cmds.fileBrowserDialog(m=4, fc=iconViewer, an='View Images', om='Import') def iconViewer(fileName, fileType): # print(fileName, fileType) iconPath = lambda type, path="": os.path.join(fileName, path, "*.%s" % type ) iconType = "xpm" paths = glob.glob(iconPath(iconType)) print(iconPath(iconType), fileName, paths) cmds.window(title="Icon Viewer", w=300, h=300) cmds.scrollLayout() cmds.rowColumnLayout(nc=10) for path in paths: pathPieces = os.path.split(path) cmds.symbolButton(i=path, c=(lambda x: punched(path, pathPieces[1]))) cmds.showWindow()
def sourceFilesPath(self): cmds.fileBrowserDialog( m = 4, fc = self.getSrcDir, ft = "directory", an = "Select the folder that contains the 'openpipeline' directory")
def fl_addFolder(self, *args): cmds.fileBrowserDialog(m=4, fc=self.fl_addFolderHandler, an='Select a folder...', om='Import')
def setPathDialog(self, *args): cmds.fileBrowserDialog(m=4, fc=self.setPath, an='Set Anim Writer Path')
def browseIt(): mc.fileBrowserDialog(m=4, fc=dirPath, ft='directory', an='Choose Directory') return