From 7710a39a1e4aff96de5a2c5d851dd45263aa52b1 Mon Sep 17 00:00:00 2001 From: alexanderrichter Date: Mon, 10 Jul 2017 21:13:00 +0200 Subject: [PATCH] software: added PLEX tab (with open folder func) maya: merged menu into userSetup, decorator into maya_util --- data/project/default/software.yml | 28 +++++++++++++++------- lib/classes/software.py | 12 ++++------ lib/libFileFolder.py | 4 ++-- software/maya/scripts/maya_utils.py | 2 +- software/maya/scripts/menu.py | 37 ----------------------------- software/maya/userSetup.py | 25 ++++++++++++++++--- 6 files changed, 49 insertions(+), 59 deletions(-) delete mode 100644 software/maya/scripts/menu.py diff --git a/data/project/default/software.yml b/data/project/default/software.yml index b052048..8ed8c49 100644 --- a/data/project/default/software.yml +++ b/data/project/default/software.yml @@ -6,6 +6,7 @@ # author = Alexander Richter #********************************************************************* + #************************ # MAYA MAYA: @@ -43,15 +44,22 @@ MAYA: MENU: + + - Plex: + open_scene_folder: menuItem(p="{}", l='Open Scene Folder', c='import libFileFolder; libFileFolder.open_folder(cmds.file(q=True, sceneName=True))') + open_project_folder: menuItem(p="{}", l='Open Project Folder', c='import libFileFolder;import libData; libFileFolder.open_folder(libData.get_data("project")["path"])') + + - break: menuItem(p="{}", d=True) + # - Save: menuItem(p="{}", l='Save', c='from util import arSave; reload(arSave); arSave.main()') # - Load: menuItem(p="{}", l='Load', c='from util import arSaveAs; reload(arSaveAs); arSaveAs.main(True)') - # - break: menuItem(p="{}", d=True) + # - break: menuItem(p="{}", d=True) - # - Util: - # position_selected: menuItem(p="{}", l='Position Selected', c='import maya_utils; maya_utils.position_selected()') + - Utils: + position_selected: menuItem(p="{}", l='Position to First Selection', c='import maya_utils; maya_utils.position_selected()') - - break: menuItem(p="{}", d=True) + - break: menuItem(p="{}", d=True) - Report: menuItem(p="{}", l='Report', c='import libFunc; libFunc.get_help("issues")') - Help: menuItem(p="{}", l='Help', c='import libFunc; libFunc.get_help()') @@ -73,7 +81,7 @@ MAYA: # NUKE NUKE: version: &NUKE_VERSION 10.5 - version_long: &NUKE_VERSION_LONG !join [*NUKE_VERSION, v2] + version_long: &NUKE_VERSION_LONG !join [*NUKE_VERSION, v1] start: !join ['start "" Nuke', *NUKE_VERSION ,'.exe --nukex "{}"'] @@ -102,6 +110,12 @@ NUKE: MENU: + - Plex: + open_scene_folder: addCommand('Open Scene Folder', 'import libFileFolder; libFileFolder.open_folder(nuke.root().knob("name").value())') + open_project_folder: addCommand('Open Project Folder', 'import libFileFolder;import libData; libFileFolder.open_folder(libData.get_data("project")["path"])') + + - break: addSeparator() + # - Save: "addCommand('Save', 'import menu; save()', 'ctrl+alt+s', 'save.ico')" # - Load: "addCommand('Load', 'import menu; load()', 'ctrl+alt+l', 'load.ico')" @@ -114,10 +128,6 @@ NUKE: - Report: addCommand('Report', 'import libFunc; libFunc.get_help("issues")', 'ctrl+alt+r', 'report.ico') - Help: addCommand('Help', 'import libFunc; libFunc.get_help()', 'ctrl+alt+h', 'help.ico') - - break: addSeparator() - - #- Others: - # Sub: addCommand('Script', '') #************************ diff --git a/lib/classes/software.py b/lib/classes/software.py index d97150d..601fa4d 100644 --- a/lib/classes/software.py +++ b/lib/classes/software.py @@ -88,8 +88,7 @@ def start(self, software='', open_file=''): def __call__(self): LOG.info('SOFTWARE: {} {} - {}\n\ - ENV: {}'.format(self._software, self._version, self._path, - self._env)) + ENV: {}'.format(self._software, self._version, self._path, self._env)) #************************ @@ -143,12 +142,10 @@ def add_menu(self, menu_node, new_command): import maya.cmds as cmds cmd = ('cmds.{}'.format(item)).format(menu_node) eval(cmd) - elif self._software == 'nuke': - eval('menu_node.{}'.format(item)) - else: - LOG.debug('CANT find software: {}'.format(software)) + elif self._software == 'nuke': eval('menu_node.{}'.format(item)) + else: LOG.debug('CANT find software: {}'.format(software)) except: - LOG.error('DATA Menu couldnt be created', exc_info=True) + LOG.error('SOFTWARE Menu couldnt be created', exc_info=True) def print_header(self): @@ -188,6 +185,7 @@ def print_header(self): print('') # ******************** + def print_checked_header(self, text, content, func): try: func diff --git a/lib/libFileFolder.py b/lib/libFileFolder.py index d0ba8dc..edf1a11 100644 --- a/lib/libFileFolder.py +++ b/lib/libFileFolder.py @@ -35,7 +35,7 @@ def create_folder(path): try: os.makedirs(path) except: - LOG.info('CANT create folder: {}'.format(path)) + LOG.warning('CANT create folder: {}'.format(path)) # @BRIEF opens folder even if file is given def open_folder(path): @@ -44,7 +44,7 @@ def open_folder(path): path = os.path.dirname(path) webbrowser.open(path) else: - LOG.info('UNVALID path: {}'.format(path)) + LOG.warning('UNVALID path: {}'.format(path)) return path diff --git a/software/maya/scripts/maya_utils.py b/software/maya/scripts/maya_utils.py index 8a53850..760dd04 100644 --- a/software/maya/scripts/maya_utils.py +++ b/software/maya/scripts/maya_utils.py @@ -36,7 +36,7 @@ def position_selected(): cam_new.rotate.set(cam_origin.rotate.get()) cam_new.scale.set(cam_origin.scale.get()) else: - LOG.warning("FAIL : Need at least 2 selections") + LOG.warning("FAIL : Need at least 2 selections to set everything on the first selection position.") #************************ diff --git a/software/maya/scripts/menu.py b/software/maya/scripts/menu.py deleted file mode 100644 index 96fe0f7..0000000 --- a/software/maya/scripts/menu.py +++ /dev/null @@ -1,37 +0,0 @@ -#********************************************************************* -# content = maya menu -# version = 0.6.0 -# date = 2017-07-10 -# -# license = MIT -# copyright = Copyright 2017 Animationsinstitut -# author = Alexander Richter -#********************************************************************* -# This source file has been developed within the scope of the -# Technical Director course at Filmakademie Baden-Wuerttemberg. -# http://td.animationsinstitut.de -#********************************************************************* - -import os - -import maya.cmds as cmds - -from tank import Tank - - -#************************* - # MENU -def load_menu(): - delete_menu() - - menu = cmds.menu(os.getenv('PROJECT_NAME').replace(' ',''), hm = 1, p = 'MayaWindow', - l = os.getenv('PROJECT_NAME').replace(' ',''), to = 1, ) - - for menu_item in Tank().data['software']['MAYA']['MENU']: - Tank().software.add_menu(menu, menu_item) - - -def delete_menu(): - if cmds.menu(os.getenv('PROJECT_NAME').replace(' ',''), query = True, exists = True): - cmds.deleteUI(os.getenv('PROJECT_NAME').replace(' ',''), menu = True) - diff --git a/software/maya/userSetup.py b/software/maya/userSetup.py index bb45f85..8de1288 100644 --- a/software/maya/userSetup.py +++ b/software/maya/userSetup.py @@ -30,11 +30,30 @@ print "MENU" try: - cmds.evalDeferred("from scripts import menu\nmenu.load_menu()") + cmds.evalDeferred("load_menu()") print " ON - menu" -except: - print " OFF - menu" +except: print " OFF - menu" print " ON - shelf" print "" + + + + +#************************* + # MENU +def load_menu(): + delete_menu() + + menu = cmds.menu(os.getenv('PROJECT_NAME').replace(' ',''), hm = 1, p = 'MayaWindow', + l = os.getenv('PROJECT_NAME').replace(' ',''), to = 1, ) + + for menu_item in Tank().data['software']['MAYA']['MENU']: + Tank().software.add_menu(menu, menu_item) + + +def delete_menu(): + if cmds.menu(os.getenv('PROJECT_NAME').replace(' ',''), query = True, exists = True): + cmds.deleteUI(os.getenv('PROJECT_NAME').replace(' ',''), menu = True) +