def ok(self): """ Dialog accept function. """ # Normalise paths and strip trailing slash self.winPath = os_wrapper.absolutePath(self.ui.jobRootPathWin_lineEdit.text(), stripTrailingSlash=True) self.osxPath = os_wrapper.absolutePath(self.ui.jobRootPathOSX_lineEdit.text(), stripTrailingSlash=True) self.linuxPath = os_wrapper.absolutePath(self.ui.jobRootPathLinux_lineEdit.text(), stripTrailingSlash=True) self.jobsRelPath = self.ui.jobsRelPath_lineEdit.text() self.accept()
def set_env(): os.environ['DEADLINE_PATH'] = os.path.dirname( os.environ['IC_DEADLINE_EXECUTABLE']) if os.environ['IC_RUNNING_OS'] == "MacOS": os.environ['IC_DEADLINE_CMD_EXECUTABLE'] = os_wrapper.absolutePath( '$DEADLINE_PATH/../../../Resources/deadlinecommand') else: # Windows or Linux os.environ['IC_DEADLINE_CMD_EXECUTABLE'] = os_wrapper.absolutePath( '$DEADLINE_PATH/deadlinecommand')
def set_env(): os.environ['DJV_PLAY'] = os.environ['IC_DJV_EXECUTABLE'] os.environ['DJV_LIB'] = os_wrapper.absolutePath( '%s/../lib' % os.path.dirname(os.environ['IC_DJV_EXECUTABLE'])) if os.environ['IC_RUNNING_OS'] == "Windows": os.environ['DJV_CONVERT'] = os_wrapper.absolutePath( '%s/djv_convert.exe' % os.path.dirname(os.environ['IC_DJV_EXECUTABLE'])) else: # Mac OS X and Linux os.environ['DJV_CONVERT'] = os_wrapper.absolutePath( '%s/djv_convert' % os.path.dirname(os.environ['IC_DJV_EXECUTABLE']))
def w_fileName_preset(writeNode, filePath, presetType, ext, proxy=True): """ Sets the fileName presets. """ fileName = '%s_%s.%s.%s' % (os.environ['IC_SHOT'], presetType, r'%04d', ext) # fullPath = os.path.join(filePath, 'full', fileName) # fileName = '$IC_SHOT_%s.%04d.%s' % (presetType, ext) fullPath = os_wrapper.absolutePath('%s/full/%s' % (filePath, fileName)) writeNode.knob('file').setValue(fullPath) if proxy: # proxyPath = os.path.join(filePath, 'proxy', fileName) proxyPath = os_wrapper.absolutePath('%s/proxy/%s' % (filePath, fileName)) writeNode.knob('proxy').setValue(proxyPath)
def iconTint(self, icon_name, tint=None): """ Return a QIcon using the specified PNG or SVG image. If tint (QColor) is given, tint the image with the given color. """ search_locations = [ 'icons', os_wrapper.absolutePath('$IC_FORMSDIR/icons') ] if icon_name.endswith('svg'): w, h = 64, 64 svg_renderer = QtSvg.QSvgRenderer( self.checkFilePath(icon_name, searchpath=search_locations)) image = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32) image.fill( 0x00000000) # Set the ARGB to 0 to prevent rendering artifacts svg_renderer.render(QtGui.QPainter(image)) pixmap = QtGui.QPixmap.fromImage(image) else: pixmap = QtGui.QPixmap( self.checkFilePath(icon_name, searchpath=search_locations)) # Initialize painter to draw on a pixmap and set composition mode if tint is not None: painter = QtGui.QPainter() painter.begin(pixmap) painter.setCompositionMode(painter.CompositionMode_SourceIn) painter.setBrush(tint) painter.setPen(tint) painter.drawRect(pixmap.rect()) painter.end() return pixmap
def file_open(self, filepath): """ Open the specified file. """ # Remove backslashes from path as this causes issues on Windows... filepath = os_wrapper.absolutePath(filepath) # print("Loading: %s" % filepath) # Hide UI to prevent is stealing focus from Houdini's own dialog... self.file_open_ui.hide() try: hou.hipFile.load(file_name=filepath) self.set_hip_and_job_vars( set_hip_explicit=os.path.dirname(filepath)) return filepath except hou.OperationFailed as e: dialog = prompt.dialog() dialog.display(str(e), "Error Opening File", conf=True) return False except hou.LoadWarning as e: dialog = prompt.dialog() dialog.display(str(e), "Warning", conf=True) return False
def get_versions(file_list): """ Detect versions of a file from the provided list of files. Return a nested dictionary in the format: base_file_prefix: { version: filepath, version: filepath }, base_file_prefix: { version: filepath } ... etc. """ seq = {} for filepath in file_list: filepath = os_wrapper.absolutePath(filepath) meta = parse(filepath) if '<description>' in meta: prefix = ".".join( [meta['<shot>'], meta['<discipline>'], meta['<description>']]) else: prefix = ".".join([meta['<shot>'], meta['<discipline>']]) v_int = version_to_int(meta['<version>']) try: seq[prefix][v_int] = filepath except KeyError: seq[prefix] = {v_int: filepath} return seq
def update_recents_menu(self, menu): """ Populate the recent files menu or disable it if no recent files in list. """ recent_files.recents.reload() # Force reload of datafile recent_file_list = recent_files.recents.get('maya') # Delete all items in the pop-up menu mc.menu(menu, edit=True, deleteAllItems=True) # Re-populate the items in the pop-up menu for item in recent_file_list: filepath = os_wrapper.absolutePath(item) # Create the menu items... menu_name = os.path.basename(filepath) menu_cmd = str('session.scnmgr.file_open(\"%s\")' % filepath) mc.menuItem(item, label=menu_name, command=menu_cmd, parent=menu) # If recent file list contains no entries, disable menu enable = True; if len(recent_file_list) == 0: enable = False if len(recent_file_list) == 1 and recent_file_list[0] == "": enable = False try: mc.menuItem(menu, edit=True, enable=enable) except RuntimeError: mc.menu(menu, edit=True, enable=enable)
def read_create(): """ Create a custom GPS Read node. """ readDir = os_wrapper.absolutePath('$IC_SHOTPATH/') dialogPathLs = nuke.getClipname('Read File(s)', default=readDir, multiple=True) if dialogPathLs: for dialogPath in dialogPathLs: try: filePath, frameRange = dialogPath.split(' ') startFrame, endFrame = frameRange.split('-') except ValueError: filePath = dialogPath startFrame, endFrame = os.environ['IC_STARTFRAME'], os.environ[ 'IC_ENDFRAME'] # Make filePath relative filePath = os_wrapper.relativePath(filePath, 'IC_JOBPATH', tokenFormat='nuke') readNode = nuke.createNode('Read', 'name GPS_Read') readNode.knob('file').setValue(filePath) readNode.knob('cacheLocal').setValue('always') readNode.knob('cached').setValue('True') readNode.knob('first').setValue(int(startFrame)) readNode.knob('last').setValue(int(endFrame)) return readNode
def update_recents_menu(self, menu=None): """ Populate the recent files menu or disable it if no recent files in list. """ if menu is None: menu = self.icOpenRecentMenu else: self.icOpenRecentMenu = menu # Store a reference to the menu recent_files.recents.reload() # Force reload of datafile recent_file_list = recent_files.recents.get('nuke') # Delete all items in the pop-up menu menu.clearMenu() # Re-populate the items in the pop-up menu for item in recent_file_list: filepath = os_wrapper.absolutePath(item) # Create the menu items... # Forward slashes need escaping to prevent Nuke from interpreting # them as sub-menus. # Cast menu command to string as Nuke gives error if unicode. menu_name = os.path.basename(filepath).replace('/', '\/') menu_cmd = str('session.scnmgr.file_open(\"%s\")' % filepath) menu.addCommand(menu_name, menu_cmd) # If recent file list contains no entries, disable menu enable = True if len(recent_file_list) == 0: enable = False if len(recent_file_list) == 1 and recent_file_list[0] == "": enable = False menu.setEnabled(enable)
def addSequence(self): """ Open a dialog to select files to add. """ filename = self.fileDialog(self.getBrowseDir()) if filename: filename = os_wrapper.absolutePath(filename) self.lastDir = os.path.dirname(filename) self.updateTaskListFile(filename)
def addDirectory(self): """ Open a dialog to select a folder to add files from. """ dirname = self.folderDialog(self.getBrowseDir()) if dirname: dirname = os_wrapper.absolutePath(dirname) self.lastDir = dirname self.updateTaskListDir(dirname)
def set_env(): os.environ['HOUDINI_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/houdini') + os.pathsep \ + os_wrapper.absolutePath('$IC_BASEDIR/rsc/houdini/env') + os.pathsep + "&" + os.pathsep # os.environ['HOUDINI_SCRIPT_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/houdini/scripts') + os.pathsep + "&" + os.pathsep os.environ['HOUDINI_UI_ICON_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/houdini/icons') + os.pathsep \ + os_wrapper.absolutePath('$IC_FORMSDIR/icons') + os.pathsep + "&" + os.pathsep os.environ['HOUDINI_TOOLBAR_PATH'] = os_wrapper.absolutePath( '$IC_BASEDIR/rsc/houdini/shelves') + os.pathsep + "&" + os.pathsep # os.environ['JOB'] = os.environ['IC_HOUDINI_PROJECT_DIR'] # os.environ['HIP'] = os_wrapper.absolutePath('$IC_HOUDINI_PROJECT_DIR/scenes') if os.environ['IC_RUNNING_OS'] == "Windows": # os.environ['HOUDINI_TEXT_CONSOLE'] = "1" # Use a normal shell window for console output os.environ[ 'HOUDINI_DISABLE_CONSOLE'] = "1" # Disable text console completely # os.environ['HOUDINI_NO_ENV_FILE'] = "1" # Don't load the user's houdini.env # os.environ['HOUDINI_NO_ENV_FILE_OVERRIDES'] = "1" # Don't allow overrides to existing vars from the user's houdini.env # os.environ['HSITE'] = os_wrapper.absolutePath('$IC_FILESYSTEM_ROOT/_Library/3D/Houdini') # Store this in app settings / IC global prefs?
def browseFolder(self, lineEdit): """ Browse for a folder and put the result into the specified lineEdit field. """ starting_dir = os_wrapper.absolutePath(lineEdit.text()) result = self.parent.folderDialog(starting_dir) if result: result = os_wrapper.relativePath(result, 'IC_ASSETLIBRARY') result = os_wrapper.relativePath(result, 'IC_FILESYSTEM_ROOT') lineEdit.setText(result)
def set_hip_and_job_vars(self, set_hip_explicit=None): """ Set the $HIP and $JOB env vars to the correct location. $HIP defaults to user scene dir unless set_hip_explicit is given. """ if set_hip_explicit is None: hip_dir = os_wrapper.absolutePath( '$IC_HOUDINI_SCENES_DIR/$IC_USERNAME') else: hip_dir = os_wrapper.absolutePath(set_hip_explicit) job_dir = os_wrapper.absolutePath('$IC_HOUDINI_PROJECT_DIR') # Create $HIP dir if it doesn't exist if not os.path.isdir(hip_dir): os_wrapper.createDir(hip_dir) # Set vars os.environ['HIP'] = hip_dir hou.putenv('HIP', hip_dir) os.environ['JOB'] = job_dir hou.putenv('JOB', job_dir)
def renderPreview(self, item, column): """ Launches sequence viewer when entry is double-clicked. """ #print item.text(column), column #path = sequence.getFirst(os_wrapper.absolutePath(item.text(4))) path = os_wrapper.absolutePath(item.text(4)) path = path.replace("#", self.ui.frame_spinBox.text()) #print path #djvOps.viewer(path) # from shared import launchApps # launchApps.djv(path) os.system('/usr/local/djv-1.1.0-Linux-64/bin/djv_view.sh %s' % path)
def w_path_preset(writeNode, presetType='Precomp'): """ Sets the filePath presets. """ if 'Plate_' in presetType: presetType = presetType.replace('Plate_', '') filePath = os.path.join('[getenv IC_SHOTPATH]', 'plate', presetType) fullPath = os.path.join(os.environ['IC_SHOTPATH'], 'plate', presetType) else: filePath = os.path.join('[getenv IC_NUKE_RENDERS_DIR]', presetType) fullPath = os.path.join(os.environ['IC_NUKE_RENDERS_DIR'], presetType) version = vCtrl.version(fullPath) filePath = os_wrapper.absolutePath(os.path.join(filePath, version)) return filePath
def set_env(): if os.environ['IC_NUKE_EXECUTABLE'] != "": os.environ['MARI_NUKEWORKFLOW_PATH'] = os.environ['IC_NUKE_EXECUTABLE'] os.environ['MARI_DEFAULT_IMAGEPATH'] = os.environ[ 'IC_MARI_SOURCEIMAGES_DIR'] os.environ['MARI_SCRIPT_PATH'] = os_wrapper.absolutePath( '$IC_BASEDIR/rsc/mari/scripts') os.environ['MARI_CACHE'] = os.environ['IC_MARI_SCENES_DIR'] os.environ['MARI_WORKING_DIR'] = os.environ['IC_MARI_SCENES_DIR'] os.environ['MARI_DEFAULT_GEOMETRY_PATH'] = os.environ['IC_SHOTPUBLISHDIR'] os.environ['MARI_DEFAULT_ARCHIVE_PATH'] = os.environ['IC_MARI_SCENES_DIR'] os.environ['MARI_DEFAULT_EXPORT_PATH'] = os.environ['IC_MARI_TEXTURES_DIR'] os.environ['MARI_DEFAULT_IMPORT_PATH'] = os.environ['IC_MARI_TEXTURES_DIR'] os.environ['MARI_DEFAULT_RENDER_PATH'] = os.environ['IC_MARI_RENDERS_DIR'] os.environ['MARI_DEFAULT_CAMERA_PATH'] = os.environ['IC_SHOTPUBLISHDIR']
def update_recents_menu(self): """ Populate the recent files menu or disable it if no recent files in list. Returns a list to populate the custom recent files menu. """ recent_files.recents.reload() # Force reload of datafile recent_file_list = recent_files.recents.get('houdini') menu_items = [] for item in recent_file_list: filepath = os_wrapper.absolutePath(item) menu_name = os.path.basename(filepath) menu_items.append(filepath) menu_items.append(menu_name) return menu_items
def updateUserPrefsLocation(self, state, value): """ Update user prefs location based on the setting above. """ if state: if value == 'server': config_dir = self.frame.configDir_lineEdit.text() path = os.path.join(config_dir, 'users', os.environ['IC_USERNAME']) elif value == 'home': metadata = self.frame.metadataDir_lineEdit.text() path = os.path.join(os.environ['IC_USERHOME'], metadata) path = os_wrapper.absolutePath(path) path = os_wrapper.relativePath(path, 'IC_BASEDIR') path = os_wrapper.relativePath(path, 'IC_USERHOME') path = os_wrapper.relativePath(path, 'IC_USERNAME') self.frame.userPrefs_lineEdit.setText(path)
def deleteShots(self): """ Delete the selected shot(s). TODO: implement properly """ # Confirmation dialog dialog_title = "Delete shot: %s" % self.shot dialog_msg = "Are you sure?" dialog = prompt.dialog() if dialog.display(dialog_msg, dialog_title): shot_path = os_wrapper.absolutePath("%s/$IC_SHOTSDIR/%s" % (self.job_path, self.shot)) result, msg = os_wrapper.remove(shot_path) if result: verbose.message("Shot '%s' deleted: %s" % (self.shot, self.job_path)) self.populateShots() else: dialog.display(msg, "Failed to delete shot", conf=True)
def match_files(base_dir, file_filter): """ Match files based on the convention given in file_filter and return as a list. """ file_extensions = os.environ['SCNMGR_FILE_EXT'].split(os.pathsep) matches = [] for filetype in file_extensions: search_pattern = os.path.join(base_dir, file_filter + filetype) for filepath in glob.glob(search_pattern): # Only add files, not directories or symlinks if os.path.isfile(filepath) \ and not os.path.islink(filepath): filepath = os_wrapper.absolutePath(filepath) matches.append(filepath) return matches
def file_save_as(self, filepath): """ Save the current file to the specified filepath. If the destination dir doesn't exist, Houdini will automatically create it. """ # Remove backslashes from path as this causes issues on Windows... filepath = os_wrapper.absolutePath(filepath) # print("Saving: %s" % filepath) # Hide UI to prevent is stealing focus from Houdini's own dialog... self.file_save_ui.hide() try: hou.hipFile.save(filepath) self.set_hip_and_job_vars( set_hip_explicit=os.path.dirname(filepath)) recent_files.recents.put(filepath) return filepath except hou.OperationFailed as e: dialog = prompt.dialog() dialog.display(str(e), "Error Saving File", conf=True) return False
def loadDailies(dailies_categories=['CGI', 'Flame', 'Edit']): """ Load or create project and import dailies. """ filename = os_wrapper.absolutePath("$IC_HIERO_EDITORIAL_DIR/$IC_JOB.hrox") if os.path.isfile(filename): hiero_project = hc.openProject(filename) else: # Create a new project hiero_project = hc.newProject() clipsBin = hiero_project.clipsBin() # Create some bins & attach to the project for cat in dailies_categories: _bin = hc.Bin(cat) clipsBin.addItem(_bin) # hiero_project.saveAs(filename) for cat in dailies_categories: _bin = hc.findItemsInProject(hiero_project, hc.Bin, cat, verbose=0)[0] _path = os.path.join(os.environ['IC_WIPS_DIR'], cat) loadItems(_path, _bin, emptyBin=True)
def set_env(): os.environ['C4D_PLUGINS_DIR'] = os_wrapper.absolutePath( '$IC_FILESYSTEM_ROOT/_Library/3D/C4D/$IC_C4D_VERSION/plugins') os.environ['C4D_SCRIPTS_DIR'] = os_wrapper.absolutePath( '$IC_FILESYSTEM_ROOT/_Library/3D/C4D/$IC_C4D_VERSION/scripts')
def set_env(): # Icarus env vars # (N.B. Project path vars are set in templates/projectDir.xml) os.environ['IC_MAYA_RENDER_EXECUTABLE'] = os_wrapper.absolutePath( '%s/Render' % os.path.dirname(os.environ['IC_MAYA_EXECUTABLE'])) os.environ['IC_MAYA_SHARED_RESOURCES'] = os_wrapper.absolutePath( '$IC_FILESYSTEM_ROOT/_Library/3D/Maya' ) # Store this in app settings / IC global prefs? # Maya config vars os.environ['MAYA_DEBUG_ENABLE_CRASH_REPORTING'] = "0" os.environ['MAYA_ENABLE_LEGACY_VIEWPORT'] = "1" os.environ[ 'MAYA_FORCE_PANEL_FOCUS'] = "0" # This should prevent panel stealing focus from Qt window on keypress. os.environ[ 'MAYA_DISABLE_CLIC_IPM'] = "1" # Disable the In Product Messaging button (should improve Maya startup & shutdown time). os.environ[ 'MAYA_DISABLE_CIP'] = "1" # Disable the Customer Involvement Program (should improve Maya startup & shutdown time). #os.environ['MAYA_MODULE_PATH'] = #os.environ['MAYA_PRESET_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/presets') #os.environ['MI_CUSTOM_SHADER_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/shaders/include') #os.environ['MI_LIBRARY_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/shaders') #os.environ['VRAY_FOR_MAYA_SHADERS'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/shaders') #os.environ['VRAY_FOR_MAYA2014_PLUGINS_x64'] += os.pathsep + os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/plugins') maya_ver = os.environ['IC_MAYA_VERSION'] pluginsPath = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/plugins') + os.pathsep \ + os_wrapper.absolutePath('$IC_MAYA_SHARED_RESOURCES/%s/plug-ins' % maya_ver) scriptsPath = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/env') + os.pathsep \ + os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/scripts') + os.pathsep \ + os_wrapper.absolutePath('$IC_MAYA_PROJECT_DIR/scripts') + os.pathsep \ + os_wrapper.absolutePath('$IC_JOBPUBLISHDIR/scripts') + os.pathsep \ + os_wrapper.absolutePath('$IC_SHOTPUBLISHDIR/scripts') + os.pathsep \ + os_wrapper.absolutePath('$IC_MAYA_SHARED_RESOURCES/scripts') + os.pathsep \ + os_wrapper.absolutePath('$IC_MAYA_SHARED_RESOURCES/%s/scripts' % maya_ver) iconsPath = os_wrapper.absolutePath('$IC_BASEDIR/rsc/maya/icons') + os.pathsep \ + os_wrapper.absolutePath('$IC_JOBPUBLISHDIR/icons') + os.pathsep \ + os_wrapper.absolutePath('$IC_MAYA_SHARED_RESOURCES/%s/icons' % maya_ver) if os.environ[ 'IC_RUNNING_OS'] == "Linux": # Append the '%B' bitmap placeholder token required for Linux iconsPathsModified = [] for path in iconsPath.split(os.pathsep): iconsPathsModified.append(path + r"/%B") iconsPath = os.pathsep.join(n for n in iconsPathsModified) os.environ['MAYA_SHELF_PATH'] = os_wrapper.absolutePath( '$IC_JOBPUBLISHDIR/ma_shelves') # For custom job shelf os.environ['MAYA_PLUG_IN_PATH'] = pluginsPath os.environ['MAYA_SCRIPT_PATH'] = scriptsPath # os.environ['PYTHONPATH'] = scriptsPath # this should only happen at Maya launch os.environ['XBMLANGPATH'] = iconsPath
def set_env(): os.environ['NUKE_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/nuke') + os.pathsep \ + os_wrapper.absolutePath('$IC_BASEDIR/rsc/nuke/env')
def set_env(): os.environ['RF_RSC'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/realflow') os.environ['RF_STARTUP_PYTHON_SCRIPT_FILE_PATH'] = os_wrapper.absolutePath( '$IC_BASEDIR/rsc/realflow/scripts/startup.rfs') os.environ['RFOBJECTSPATH'] = os_wrapper.absolutePath( '$IC_SHOTPUBLISHDIR/ma_geoCache/realflow')
def set_env(): os.environ['IC_HIERO_EDITORIAL_DIR'] = os_wrapper.absolutePath('$IC_JOBPATH/../Editorial/Hiero') # Shouldn't hardcode this os.environ['HIERO_PLUGIN_PATH'] = os_wrapper.absolutePath('$IC_BASEDIR/rsc/hiero')
def set_env(): os.environ['MUDBOX_PLUG_IN_PATH'] = os_wrapper.absolutePath( '$IC_BASEDIR/rsc/mudbox/plugins') os.environ['MUDBOX_IDLE_LICENSE_TIME'] = "60"