def testRenderRmanInject(self): if hou.isApprentice(): return rib_file = "test/cortexRmanInject_testData/testrman.$F4.rib" hou.hipFile.clear(suppress_save_prompt=True) self.testCreateRmanInject() # create a camera camera = hou.node("/obj").createNode("cam", node_name="cam1") self.assert_(camera) # create a mantra rop rman = hou.node("/out").createNode("rib", node_name="rman_out") self.assert_(rman) rman.parm("camera").set(camera.path()) # set path rman.parm("rib_outputmode").set(True) rman.parm("soho_diskfile").set(rib_file) # render rman.render(frame_range=(1, 10)) # check ribs made it ribs = glob.glob("test/cortexRmanInject_testData/testrman.????.rib") self.assertEqual(len(ribs), 10) # make sure the procedurals got in there procs = [] for rib in ribs: for line in open(rib): if 'Procedural "DynamicLoad"' in line: procs.append(line.strip()) self.assertEqual(len(procs), 10) self.failUnless("iePython" in procs[0]) self.failUnless("['-radius', '1', '-theta', '360']" in procs[0]) self.failUnless("['-radius', '2', '-theta', '360']" in procs[1]) self.failUnless("['-radius', '3', '-theta', '360']" in procs[2]) self.failUnless("[-1 1 -1 1 -1 1]" in procs[0])
def __init__(self, parent=None): super(MyWindow, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint) self.mw = QtCompat.loadUi(file_interface) self.setCentralWidget(self.mw) self.setWindowTitle("Hou2Cloud") stylesheet = hou.qt.styleSheet() self.setStyleSheet(stylesheet) #Clear Conditions self.mw.listWidget.clear() self.mw.header_lbl.setPixmap(QPixmap(header)) self.mw.bttn_link.setText("Link Google Account") #Get Init Conditions self.Start() #Check if Houdini is running Apprentice. self.mw.combo_file.clear() if hou.isApprentice() == False: self.mw.combo_file.addItem(".hip") self.mw.combo_file.addItem(".hipnc") self.mw.combo_file.addItem(".hiplc") #Button Assignment #Link to Google Drive self.mw.bttn_link.clicked.connect(self.linkDrive) self.mw.bttn_link.setIcon(QIcon(gicon)) #Get File List from Drive self.mw.bttn_getFiles.clicked.connect(self.getFiles) self.mw.bttn_getFiles.setIcon(QIcon(gicon)) #Clear List self.mw.bttn_clear.clicked.connect(self.clearList) self.mw.bttn_clear.setIcon(QIcon(hicon)) #Upload Button self.mw.bttn_upload.clicked.connect(self.upload) self.mw.bttn_upload.setIcon(QIcon(gicon))
def testRenderRmanInject(self): if hou.isApprentice(): return rib_file = "test/cortexRmanInject_testData/testrman.$F4.rib" hou.hipFile.clear(suppress_save_prompt=True) self.testCreateRmanInject() # create a camera camera = hou.node("/obj").createNode("cam", node_name="cam1") self.assert_( camera ) # create a mantra rop rman = hou.node("/out").createNode("rib", node_name="rman_out") self.assert_( rman ) rman.parm("camera").set(camera.path()) # set path rman.parm("rib_outputmode").set(True) rman.parm("soho_diskfile").set(rib_file) # render rman.render(frame_range=(1, 10)) # check ribs made it ribs = glob.glob("test/cortexRmanInject_testData/testrman.????.rib") self.assertEqual( len(ribs), 10 ) # make sure the procedurals got in there procs = [] for rib in ribs: for line in open(rib): if 'Procedural "DynamicLoad"' in line: procs.append(line.strip()) self.assertEqual( len(procs), 10 ) self.failUnless( "iePython" in procs[0] ) self.failUnless( "['-radius', '1', '-theta', '360']" in procs[0] ) self.failUnless( "['-radius', '2', '-theta', '360']" in procs[1] ) self.failUnless( "['-radius', '3', '-theta', '360']" in procs[2] ) self.failUnless( "[-1 1 -1 1 -1 1]" in procs[0] )
def _exportAlembic(self, filePath, exportSettings, exportSelected=True, timeRange=[0,10]): if hou.isApprentice(): hou.ui.displayMessage("Alembic export is not supported in Houdini Apprentice. ") return False houdiniExp_abc = exportSettings["alembicExportHoudini"] rootNode = hou.node('obj') if exportSelected: exportList = hou.selectedNodes() else: exportList = rootNode.children() if len(exportList) == 0: hou.ui.displayMessage("Nothing to export. Aborting") return False geoNode = rootNode.createNode('geo', node_name="tmpExport") try: geoNode.allSubChildren()[0].destroy() except IndexError: pass mergeNode = geoNode.createNode('object_merge') numObj = len(exportList) mergeNode.parm('numobj').set(numObj) mergeNode.parm('xformtype').set("local") mergeNode.parm('pack').set(True) for x in range(numObj): parameter = 'objpath%s' % (x + 1) mergeNode.parm(parameter).set(exportList[x].path()) # rop sop ropSop = geoNode.createNode('rop_alembic') ropSop.setInput(0, mergeNode) ropSop.parm('filename').set(filePath) # -------------- # SET PROPERTIES # -------------- # timeline: if timeRange[0] == timeRange[1]: ropSop.parm('trange').set("off") else: ropSop.parm('trange').set("normal") ropSop.parm('f1').deleteAllKeyframes() ropSop.parm('f2').deleteAllKeyframes() ropSop.parm('f1').set(timeRange[0]) ropSop.parm('f2').set(timeRange[1]) for item in houdiniExp_abc.items(): ropSop.parm(item[0]).set(item[1]) ropSop.render() # delete the export nodes geoNode.destroy() return True
def save_as(self, version): """the save action for houdini environment """ if not version: return from stalker import Version assert isinstance(version, Version) # get the current version, and store it as the parent of the new version current_version = self.get_current_version() # initialize path variables by using update_paths() version.update_paths() # set the extension to hip if not hou.isApprentice(): version.extension = '.hip' else: version.extension = '.hipnc' # define that this version is created with Houdini version.created_with = self.name # create the folder if it doesn't exists try: os.makedirs(os.path.dirname(version.absolute_full_path)) except OSError: # dirs exist pass # houdini uses / instead of \ under windows # lets fix it # set the environment variables self.set_environment_variables(version) # set the render file name self.set_render_filename(version) # houdini accepts only strings as file name, no unicode support as I # see hou.hipFile.save(file_name=str(version.absolute_full_path)) # set the environment variables again self.set_environment_variables(version) # append it to the recent file list self.append_to_recent_files(version.absolute_full_path) # update the parent info if current_version: version.parent = current_version # update database with new version info DBSession.commit() return True
def keyGen(): ''' This function generates a validation key for host app''' if hou.isApprentice(): return 'app' else: if hou.applicationName() == 'hindie': return 'ind' else: return 'com'
def compareVersions(self): # // TODO : Find a BETTER way to compare versions. # // TODO : You may question each individual scen file for version insteas of base scene database """Compares the versions of current session and database version at cursor position""" logger.debug("Func: compareVersions") # version serialization: # vTup = hou.applicationVersion() vTup = self._getVersion() vIsApprentice = hou.isApprentice() currentVersion = float("%s.%s%s" % (vTup[0], vTup[1], vTup[2])) dbVersionAsTuple = self._currentSceneInfo["HoudiniVersion"][0] dbIsApprentice = self._currentSceneInfo["HoudiniVersion"][1] baseSceneVersion = float( "%s.%s%s" % (dbVersionAsTuple[0], dbVersionAsTuple[1], dbVersionAsTuple[2])) messageList = [] if vIsApprentice and not dbIsApprentice: msg = "Base Scene Created with Commercial License. Current Houdini session is Apprentice. Are you sure you want to continue?" messageList.append(msg) if not vIsApprentice and dbIsApprentice: msg = "Base Scene Created with Apprentice License. Current Houdini session is Commercial. Are you sure you want to continue?" messageList.append(msg) if currentVersion == baseSceneVersion: pass if currentVersion < baseSceneVersion: # version compare message = "Base Scene is created with a HIGHER Houdini version ({0}). Are you sure you want to continue?".format( baseSceneVersion) messageList.append(message) if currentVersion > baseSceneVersion: message = "Base Scene is created with a LOWER Houdini version ({0}). Are you sure you want to continue?".format( baseSceneVersion) messageList.append(message) # old or corrupted databasek return 0, "" # skip message = "" for x in messageList: message = message + "\n" + str(x) if messageList == []: return 0, message else: return -1, message
def houVer(): houTypeRaw = hou.applicationName() houApp = hou.isApprentice() houType = "houdiniDefault" addedWarning = 0 if houTypeRaw == "houdini" and houApp == True: houType = "Houdini Apprentice" addedWarning = 1 elif houTypeRaw == "houdini": houType = "Houdini" addedWarning = 0 elif houTypeRaw == "hescape": houType = "Houdini Escape" addedWarning = 1 elif houTypeRaw == "engine": houType = "Houdini Engine" addedWarning = 0 print "Launching " + houType + " Version: " + hou.applicationVersionString( ) if addedWarning == 1: print "Warning: Dynamics not accessible in this version."
def saveVersion(self, makeReference=False, versionNotes="", sceneFormat="hip", *args, **kwargs): """ Saves a version for the predefined scene. The scene json file must be present at the /data/[Category] folder. Args: userName: (String) Predefined user who initiates the process makeReference: (Boolean) If set True, make a copy of the forReference file. There can be only one 'forReference' file for each scene versionNotes: (String) This string will be hold in the json file as well. Notes about the changes in the version. *args: **kwargs: Returns: Scene DB Dictionary """ logger.debug("Func: saveVersion") if hou.isApprentice(): sceneFormat="hipnc" now = datetime.datetime.now().strftime("%d/%m/%Y-%H:%M") completeNote = "[%s] on %s\n%s\n" % (self.currentUser, now, versionNotes) sceneName = self.getSceneFile() if not sceneName: msg = "This is not a base scene (Untitled)" # cmds.warning(msg) return -1, msg sceneInfo = self.getOpenSceneInfo() if sceneInfo: ## getCurrentJson returns None if the resolved json path is missing jsonFile = sceneInfo["jsonFile"] jsonInfo = self._loadJson(jsonFile) currentVersion = len(jsonInfo["Versions"]) + 1 sceneName = "{0}_{1}_{2}_v{3}".format(jsonInfo["Name"], jsonInfo["Category"], self._usersDict[self.currentUser], str(currentVersion).zfill(3)) relSceneFile = os.path.join(jsonInfo["Path"], "{0}.{1}".format(sceneName, sceneFormat)) sceneFile = os.path.join(sceneInfo["projectPath"], relSceneFile) # killTurtle() hou.hipFile.save(file_name=sceneFile) thumbPath = self.createThumbnail(dbPath=jsonFile, versionInt=currentVersion) jsonInfo["Versions"].append( # PATH => Notes => User Initials => Machine ID => Playblast => Thumbnail # [relSceneFile, completeNote, self._usersDict[self.currentUser], (socket.gethostname()), {}, thumbPath]) # TODO : ref => Dict {"RelativePath": relSceneFile, "Note": completeNote, "User": self._usersDict[self.currentUser], "Workstation": socket.gethostname(), "Preview": {}, "Thumb": thumbPath, "Ranges": self._getTimelineRanges() } ) if makeReference: referenceName = "{0}_{1}_forReference".format(jsonInfo["Name"], jsonInfo["Category"]) relReferenceFile = os.path.join(jsonInfo["Path"], "{0}.{1}".format(referenceName, sceneFormat)) referenceFile = os.path.join(sceneInfo["projectPath"], relReferenceFile) shutil.copyfile(sceneFile, referenceFile) jsonInfo["ReferenceFile"] = relReferenceFile jsonInfo["ReferencedVersion"] = currentVersion self._dumpJson(jsonInfo, jsonFile) else: msg = "This is not a base scene (Json file cannot be found)" return -1, msg return jsonInfo
def saveBaseScene(self, categoryName, baseName, subProjectIndex=0, makeReference=False, versionNotes="", sceneFormat="hip", *args, **kwargs): """ Saves the scene with formatted name and creates a json file for the scene Args: category: (String) Category if the scene. Valid categories are 'Model', 'Animation', 'Rig', 'Shading', 'Other' userName: (String) Predefined user who initiates the process baseName: (String) Base name of the scene. Eg. 'Shot01', 'CharacterA', 'BookRig' etc... subProject: (Integer) The scene will be saved under the sub-project according to the given integer value. The 'self.subProjectList' will be searched with that integer. makeReference: (Boolean) If set True, a copy of the scene will be saved as forReference versionNotes: (String) This string will be stored in the json file as version notes. *args: **kwargs: Returns: Scene DB Dictionary """ if hou.isApprentice(): sceneFormat="hipnc" logger.debug("Func: saveBaseScene") now = datetime.datetime.now().strftime("%d/%m/%Y-%H:%M") completeNote = "[%s] on %s\n%s\n" % (self.currentUser, now, versionNotes) # Check if the base name is unique scenesToCheck = self.scanBaseScenes(categoryAs = categoryName, subProjectAs = subProjectIndex) for key in scenesToCheck.keys(): if baseName.lower() == key.lower(): msg = ("Base Scene Name is not unique!\nABORTING") self._exception(360, msg) return -1, msg projectPath = self.projectDir databaseDir = self._pathsDict["databaseDir"] scenesPath = self._pathsDict["scenesDir"] categoryPath = os.path.normpath(os.path.join(scenesPath, categoryName)) self._folderCheck(categoryPath) ## if its going to be saved as a subproject if not subProjectIndex == 0: subProjectPath = os.path.normpath(os.path.join(categoryPath, self._subProjectsList[subProjectIndex])) self._folderCheck(subProjectPath) shotPath = os.path.normpath(os.path.join(subProjectPath, baseName)) self._folderCheck(shotPath) jsonCategoryPath = os.path.normpath(os.path.join(databaseDir, categoryName)) self._folderCheck(jsonCategoryPath) jsonCategorySubPath = os.path.normpath(os.path.join(jsonCategoryPath, self._subProjectsList[subProjectIndex])) self._folderCheck(jsonCategorySubPath) jsonFile = os.path.join(jsonCategorySubPath, "{}.json".format(baseName)) else: shotPath = os.path.normpath(os.path.join(categoryPath, baseName)) self._folderCheck(shotPath) jsonCategoryPath = os.path.normpath(os.path.join(databaseDir, categoryName)) self._folderCheck(jsonCategoryPath) jsonFile = os.path.join(jsonCategoryPath, "{}.json".format(baseName)) version = 1 sceneName = "{0}_{1}_{2}_v{3}".format(baseName, categoryName, self._usersDict[self.currentUser], str(version).zfill(3)) sceneFile = os.path.join(shotPath, "{0}.{1}".format(sceneName, sceneFormat)) ## relativity update relSceneFile = os.path.relpath(sceneFile, start=projectPath) # killTurtle() hou.hipFile.save(file_name=sceneFile) thumbPath = self.createThumbnail(dbPath=jsonFile, versionInt=version) jsonInfo = {} if makeReference: # TODO // Find an elegant solution and add MA compatibility. Can be merged with makeReference function in derived class referenceName = "{0}_{1}_forReference".format(baseName, categoryName) referenceFile = os.path.join(shotPath, "{0}.{1}".format(referenceName, sceneFormat)) ## relativity update relReferenceFile = os.path.relpath(referenceFile, start=projectPath) shutil.copyfile(sceneFile, referenceFile) jsonInfo["ReferenceFile"] = relReferenceFile jsonInfo["ReferencedVersion"] = version else: jsonInfo["ReferenceFile"] = None jsonInfo["ReferencedVersion"] = None jsonInfo["ID"] = "SmHoudiniV02_sceneFile" jsonInfo["HoudiniVersion"] = [hou.applicationVersion(), hou.isApprentice()] jsonInfo["Name"] = baseName jsonInfo["Path"] = os.path.relpath(shotPath, start=projectPath) jsonInfo["Category"] = categoryName jsonInfo["Creator"] = self.currentUser jsonInfo["CreatorHost"] = (socket.gethostname()) jsonInfo["Versions"] = [ # PATH => Notes => User Initials => Machine ID => Playblast => Thumbnail {"RelativePath": relSceneFile, "Note": completeNote, "User": self._usersDict[self.currentUser], "Workstation": socket.gethostname(), "Preview": {}, "Thumb": thumbPath, "Ranges": self._getTimelineRanges() } ] jsonInfo["SubProject"] = self._subProjectsList[subProjectIndex] self._dumpJson(jsonInfo, jsonFile) # return jsonInfo return [0, ""]
def save_as(self, version): """the save action for houdini environment """ if not version: return from stalker import Version assert isinstance(version, Version) # get the current version, and store it as the parent of the new version current_version = self.get_current_version() # initialize path variables by using update_paths() version.update_paths() # set the extension to hip if not hou.isApprentice(): version.extension = '.hip' else: version.extension = '.hipnc' # define that this version is created with Houdini version.created_with = self.name # create the folder if it doesn't exists try: os.makedirs( os.path.dirname( version.absolute_full_path ) ) except OSError: # dirs exist pass # houdini uses / instead of \ under windows # lets fix it # set the environment variables self.set_environment_variables(version) # set the render file name self.set_render_filename(version) # houdini accepts only strings as file name, no unicode support as I # see hou.hipFile.save(file_name=str(version.absolute_full_path)) # set the environment variables again self.set_environment_variables(version) # append it to the recent file list self.append_to_recent_files( version.absolute_full_path ) # update the parent info if current_version: version.parent = current_version # update database with new version info DBSession.commit() return True
def save_as(self, version, run_pre_publishers=True): """the save action for houdini environment """ if not version: return from stalker import Version assert isinstance(version, Version) # get the current version, # and store it as the parent of the new version current_version = self.get_current_version() # initialize path variables by using update_paths() version.update_paths() # set the extension to hip if not hou.isApprentice(): version.extension = self.extensions[0] else: version.extension = self.extensions[1] # define that this version is created with Houdini version.created_with = self.name # create the folder if it doesn't exists try: os.makedirs(os.path.dirname(version.absolute_full_path)) except OSError: # dirs exist pass # houdini uses / instead of \ under windows # lets fix it # set the environment variables self.set_environment_variables(version) # set the render file name self.set_render_filename(version) # set the fps from stalker import Shot if version and isinstance(version.task.parent, Shot): # set to shot.fps if this is a shot related scene self.set_fps(version.task.parent.fps) else: # set to project fps self.set_fps(version.task.project.fps) # houdini accepts only strings as file name, no unicode support as I # see hou.hipFile.save(file_name=str(version.absolute_full_path)) # set the environment variables again self.set_environment_variables(version) # append it to the recent file list self.append_to_recent_files(version.absolute_full_path) # update the parent info if current_version: version.parent = current_version # update database with new version info from stalker.db.session import DBSession DBSession.commit() # create a local copy self.create_local_copy(version) return True
def saveVersion(self, makeReference=False, versionNotes="", sceneFormat="hip", insertTo=None, *args, **kwargs): """ Saves a version for the predefined scene. The scene json file must be present at the /data/[Category] folder. Args: userName: (String) Predefined user who initiates the process makeReference: (Boolean) If set True, make a copy of the forReference file. There can be only one 'forReference' file for each scene versionNotes: (String) This string will be hold in the json file as well. Notes about the changes in the version. *args: **kwargs: Returns: Scene DB Dictionary """ logger.debug("Func: saveVersion") if hou.isApprentice(): sceneFormat = "hipnc" now = datetime.datetime.now().strftime("%d/%m/%Y-%H:%M") completeNote = "[%s] on %s\n%s\n" % (self.currentUser, now, versionNotes) currentSceneName = self.getSceneFile() if not currentSceneName: msg = "This is not a base scene (Untitled)" self._exception(360, msg) return -1, msg if not insertTo: sceneInfo = self.getOpenSceneInfo() if not sceneInfo: msg = "This is not a base scene (Json file cannot be found)" self._exception(360, msg) return -1, msg else: sceneInfo = { "jsonFile": self.currentDatabasePath, "projectPath": self._pathsDict["projectDir"], "subProject": self.subProject, "category": self.currentTabName, "shotName": self.currentBaseSceneName, "version": len(self.getVersions()), "previewPath": self.currentPreviewPath, } # ingesting overrides make reference makeReference = False # sceneInfo = self.getOpenSceneInfo() if sceneInfo: ## getCurrentJson returns None if the resolved json path is missing jsonFile = sceneInfo["jsonFile"] jsonInfo = self._loadJson(jsonFile) currentVersion = len(jsonInfo["Versions"]) + 1 ## Naming Dictionary nameDict = { "baseName": jsonInfo["Name"], "categoryName": jsonInfo["Category"], "userInitials": self._usersDict[self.currentUser], "subproject": self.subProject, "date": now } sceneName = self.resolveSaveName(nameDict, currentVersion) # sceneName = "{0}_{1}_{2}_v{3}".format(jsonInfo["Name"], jsonInfo["Category"], self._usersDict[self.currentUser], # str(currentVersion).zfill(3)) relSceneFile = os.path.join( jsonInfo["Path"], "{0}.{1}".format(sceneName, sceneFormat)) absSceneFile = os.path.join(sceneInfo["projectPath"], relSceneFile) # print "absSceneFile", absSceneFile # houdini opens the scene with "\" paths but cannot resolve some inside paths. So convert them to "/" absSceneFile = absSceneFile.replace('\\', '/') # killTurtle() # hou.hipFile.save(file_name=absSceneFile) self._saveAs(absSceneFile) thumbPath = self.createThumbnail(dbPath=jsonFile, versionInt=currentVersion) # thumbPath = "" jsonInfo["Versions"].append( # PATH => Notes => User Initials => Machine ID => Playblast => Thumbnail # [relSceneFile, completeNote, self._usersDict[self.currentUser], (socket.gethostname()), {}, thumbPath]) # TODO : ref => Dict { "RelativePath": relSceneFile, "Note": completeNote, "User": self._usersDict[self.currentUser], "Workstation": socket.gethostname(), "Preview": {}, "Thumb": thumbPath, "Ranges": self._getTimelineRanges() }) if makeReference: referenceName = "{0}_{1}_forReference".format( jsonInfo["Name"], jsonInfo["Category"]) relReferenceFile = os.path.join( jsonInfo["Path"], "{0}.{1}".format(referenceName, sceneFormat)) referenceFile = os.path.join(sceneInfo["projectPath"], relReferenceFile) shutil.copyfile(absSceneFile, referenceFile) jsonInfo["ReferenceFile"] = relReferenceFile jsonInfo["ReferencedVersion"] = currentVersion self._dumpJson(jsonInfo, jsonFile) else: msg = "This is not a base scene (Json file cannot be found)" return -1, msg self.progressLogger("save", absSceneFile) return jsonInfo