def updatePopupMenu(self, textField, popupMenu): cmds.popupMenu(popupMenu, e=1, dai=1) cmds.setParent(popupMenu, menu=1) path = cmds.textFieldGrp(textField, q=1, tx=1) if not cmdModel.isFile(path) and not cmdModel.isFolder(path): return None cmds.menuItem(l='Open File Browser', c=partial(cmdModel.openFileBrowser, path)) cmds.menuItem(d=1) def backToUpfolder(path, *args): path = path.replace('\\', '/') path = '/'.join(path.split('/')[:-1]) cmds.textFieldGrp(textField, e=1, tx=path) self.cmdCheckImportPathAndEditButtonCondition() self.cmdCheckServerPathAndEditButtonCondition() if cmdModel.isFile(path) or cmdModel.isFolder(path): splitPath = path.replace('\\', '/').split('/') if splitPath and splitPath[-1] != '': cmds.menuItem(l='Back', c=partial(backToUpfolder, path)) cmds.menuItem(d=1) path = path.replace('\\', '/') if cmdModel.isFile(path): path = '/'.join(path.split('/')[:-1]) def updateTextField(path, *args): cmds.textFieldGrp(textField, e=1, tx=path) self.cmdCheckImportPathAndEditButtonCondition() self.cmdCheckServerPathAndEditButtonCondition() for root, dirs, names in os.walk(path): dirs.sort() for dir in dirs: cmds.menuItem(l=dir, c=partial(updateTextField, root + '/' + dir)) names.sort() for name in names: extension = name.split('.') if len(extension) == 1: continue extension = extension[1] if not extension.lower() in Model.targetExtensions: continue cmds.menuItem(l=name, c=partial(updateTextField, root + '/' + name)) break
def cmdChangeAnimPath(self, *args): self.updatePopupMenu(self.field_animPath, self.pu_animPath) animPath = cmds.textFieldGrp(self.field_animPath, q=1, tx=1) if cmdModel.isFile(animPath): bakeCameraPath = cmdModel.getCameraPathFromAnimPath(animPath) cmds.textFieldGrp(self.field_bakePath, e=1, tx=bakeCameraPath) self.cmdChangeBakePath()
def cmdChangeAnimPath(self, *args ): self.updatePopupMenu( self.field_animPath, self.pu_animPath ) animPath = cmds.textFieldGrp( self.field_animPath, q=1, tx=1 ) if cmdModel.isFile( animPath ): bakeCameraPath = cmdModel.getCameraPathFromAnimPath( animPath ) cmds.textFieldGrp( self.field_bakePath, e=1, tx=bakeCameraPath ) self.cmdChangeBakePath()
def updatePopupMenu( self, textField, popupMenu ): cmds.popupMenu( popupMenu, e=1, dai=1 ) cmds.setParent( popupMenu, menu=1 ) path = cmds.textFieldGrp( textField, q=1, tx=1 ) if not cmdModel.isFile(path) and not cmdModel.isFolder(path): return None cmds.menuItem( l='Open File Browser', c=partial( cmdModel.openFileBrowser, path ) ) cmds.menuItem( d=1 ) def backToUpfolder( path, *args ): path = path.replace( '\\', '/' ) path = '/'.join( path.split( '/' )[:-1] ) cmds.textFieldGrp( textField, e=1, tx=path ) self.cmdCheckImportPathAndEditButtonCondition() self.cmdCheckServerPathAndEditButtonCondition() if cmdModel.isFile(path) or cmdModel.isFolder(path): splitPath = path.replace( '\\', '/' ).split( '/' ) if splitPath and splitPath[-1] != '': cmds.menuItem( l='Back', c=partial( backToUpfolder, path ) ) cmds.menuItem( d=1 ) path = path.replace( '\\', '/' ) if cmdModel.isFile(path): path = '/'.join( path.split( '/')[:-1] ) def updateTextField( path, *args ): cmds.textFieldGrp( textField, e=1, tx=path ) self.cmdCheckImportPathAndEditButtonCondition() self.cmdCheckServerPathAndEditButtonCondition() for root, dirs, names in os.walk( path ): dirs.sort() for dir in dirs: cmds.menuItem( l= dir, c= partial( updateTextField, root+'/'+dir ) ) names.sort() for name in names: extension = name.split( '.' ) if len( extension ) == 1: continue extension = extension[1] if not extension.lower() in Model.targetExtensions:continue cmds.menuItem( l= name, c= partial( updateTextField, root+'/'+name ) ) break
def cmdCheckImportPathAndEditButtonCondition(self, *args): self.updatePopupMenu(self._tf_import, self._pu_import) importPathStr = cmds.textFieldGrp(self._tf_import, q=1, tx=1) if cmdModel.isFile(importPathStr): cmds.button(self._bt_import, e=1, en=1) else: cmds.button(self._bt_import, e=1, en=0)
def cmdCheckImportPathAndEditButtonCondition( self, *args ): self.updatePopupMenu( self._tf_import, self._pu_import ) importPathStr = cmds.textFieldGrp( self._tf_import, q=1, tx=1 ) if cmdModel.isFile( importPathStr ): cmds.button( self._bt_import, e=1, en=1 ) else: cmds.button( self._bt_import, e=1, en=0 )
def cmdCheckServerPathAndEditButtonCondition(self, *args): self.updatePopupMenu(self._tf_server, self._pu_server) serverPathStr = cmds.textFieldGrp(self._tf_server, q=1, tx=1) backupPath, backupFileName = cmdModel.getBackupPath(serverPathStr) cmds.textField(self._tf_backup, e=1, tx=backupPath) if cmdModel.isFile(serverPathStr): cmds.button(self._bt_open, e=1, en=1) else: cmds.button(self._bt_open, e=1, en=0)
def cmdCheckServerPathAndEditButtonCondition( self, *args ): self.updatePopupMenu( self._tf_server, self._pu_server ) serverPathStr = cmds.textFieldGrp( self._tf_server, q=1, tx=1 ) backupPath, backupFileName = cmdModel.getBackupPath(serverPathStr) cmds.textField( self._tf_backup, e=1, tx=backupPath ) if cmdModel.isFile( serverPathStr ): cmds.button( self._bt_open, e=1, en=1 ) else: cmds.button( self._bt_open, e=1, en=0 )