def build_render(self): ris = hou.node("/out").createNode("cenote_layered_render") ris.parm("frame1").set(1) ris.parm("frame2").set(self.shotBody.get_frame_range()) ris.parm("frame3").set(2) selected = None root = hou.node('/') camera_nodes = root.recursiveGlob('*', hou.nodeTypeFilter.ObjCamera) for cam in camera_nodes: if "shot" in cam.name(): selected = cam if not selected: qd.error( "Error selecting camera for render. Will need to be done manually." ) else: ris.parm("camera").set(selected.path()) layers = self.build_layer_string() print(layers) ris.parm("render_layers").set(layers) ris.parm("build_rops").pressButton() for node in ris.children(): if node.type().name() == "tractorsubmit_main": node.parm("job_title").set(self.shot_name + "_Test_Render") else: node.parm("override_camerares").set(True) old = node.parm("ri_display_0").unexpandedString() new = old.replace("render", "testRender") node.parm("ri_display_0").set(new)
def publish(self): selection = hou.selectedNodes() if len(selection) != 1: qd.error( 'Please select a single Houdini Digital Asset node to publish.') return if not selection[0].type().definition(): qd.error( 'Please select a Houdini Digital Asset node to publish.') return hda = selection[0] definition = hda.type().definition() self.name = definition.nodeTypeName() tool = self.project.get_tool(self.name) if not tool: tool = self.project.create_tool(self.name) self.element = tool.get_element(Asset.HDA) self.filepath = os.path.join(self.element._filepath, self.name) definition.save(self.filepath, hda) publishes = self.element.list_publishes() publishes_string_list = "" for publish in publishes: label = publish[0] + " " + publish[1] + " " + publish[2] + "\n" publishes_string_list += label self.input = qd.HoudiniInput( parent=hou.qt.mainWindow(), title="Comment ", info=publishes_string_list) self.input.submitted.connect(self.comment_results)
def get_one_fx(self, fx): element = self.sequence.get_element(os.path.join(Asset.HDA, fx)) if element.get_last_version() < 0: return filepath = element.get_last_publish()[3] try: hou.hda.installFile(filepath) except Exception as e: print(e) return try: hda = hou.node("/obj").createNode(fx) except Exception as e: qd.error("Couldn't create node of type " + fx + ". You should still be able to tab in the node manually.") try: hda.setName(fx, 1) except: pass try: hda.allowEditOfContents() except: pass
def results(self, value): self.shot_name = value[0] shot = self.project.get_shot(self.shot_name) if not shot: shot = self.project.create_shot(self.shot_name) if not shot: qd.error("Get Stephanie, because something broke bad.") self.element = shot.get_element(Asset.HIP) self.path = os.path.join(self.element._filepath, "temp.hipnc") hou.hipFile.setName(self.shot_name) hou.hipFile.save(file_name=self.path, save_to_recent_files=False) publishes = self.element.list_publishes() publishes_string_list = "" for publish in publishes: label = publish[0] + " " + publish[1] + " " + publish[2] + "\n" publishes_string_list += label self.input = qd.HoudiniInput(parent=hou.qt.mainWindow(), title="Comment ", info=publishes_string_list) self.input.submitted.connect(self.comment_results)
def results(self, value): type = value[0] name = self.name # determine if asset was created or not. created = True if name is None or type is None: created = False if created: project = Project() body = project.create_asset(name, asset_type=type) if body == None: qd.error("Asset with name " + name + " already exists in pipeline.") elif self.type == AssetType.SHOT: qd.info("Asset created successfully.", "Success") else: #assembler = Assembler() #assembler.create_hda(name, body=body) qd.info("Asset created successfully.", "Success") else: qd.error("Asset creation failed.")
def results(self, value): print("Selected asset: " + value[0]) filename = value[0] self.body = Project().get_body(filename) self.element = self.body.get_element(Asset.MATERIALS) if self.element.get_last_version() >= 0: path = self.element.get_last_publish()[3] if path: createNewRef = True for child in hou.node("/stage").children(): if child.name( ) == filename + "_material_ref" and child.parm( "filepath1").eval() == path: child.parm("reload").pressButton() createNewRef = False if createNewRef: ref = hou.node("/stage").createNode("reference") ref.setName(filename + "_material_ref", 1) ref.parm("filepath1").set(path) ref.parm("primpath").set("/materials/") panes = self.getCurrentNetworkEditorPane() paths = [] for pane in panes: paths.append(pane.pwd()) hdaPath = path.split(".")[0] + ".hda" hou.hda.installFile(hdaPath) success = False for p in paths: try: for child in p.children(): if child.type().name() == re.sub( r'\W+', '', filename): child.destroy() newMat = p.createNode(re.sub(r'\W+', '', filename)) newMat.setName(filename, 1) newMat.setMaterialFlag(True) success = True except: pass if not success: for child in hou.node("/mat").children(): if child.type().name() == re.sub(r'\W+', '', filename): child.destroy() newMat = hou.node("/mat").createNode( re.sub(r'\W+', '', filename)) newMat.setName(filename, 1) newMat.setMaterialFlag(True) qd.message( "Material successfully cloned into /mat context.") else: qd.error("Nothing was cloned")
def results(self, value): print("Selected asset: " + value[0]) filename = value[0] self.body = Project().get_body(filename) self.element = self.body.get_element(Asset.GEO) if self.element: #just reference in the asset, make sure we're referencing the usda geo path = self.element.get_last_publish()[3] parts = path.split(".") path = parts[0] + ".usda" ref = hou.node("/stage").createNode("reference") ref.setName(filename + "_geo", 1) ref.parm("filepath1").set(path) #also clone into the geo context from the obj file parts = path.split(".") path = parts[0] + ".obj" geo = hou.node("/obj").createNode("geo") geo.setName(filename + "_geoRef", 1) geo.parm("scale").set(0.01) fileNode = geo.createNode("file") fileNode.parm("file").set(path) else: qd.error("Nothing was cloned")
def layout_results(self, value): self.layout_name = value[0] self.layout = Project().get_layout(self.layout_name) if self.layout is None: self.layout = Project().create_layout(self.layout_name) if self.layout is None: qd.error("Stephanie done messed up") return self.element = self.layout.get_element(Asset.LAYOUT) # make a USD ROP node rop = hou.node("/stage").createNode("usd_rop") # connect the selected node to the ROP out = hou.selectedNodes()[0] rop.setInput(0, out) # set the necessary values in the ROP self.savePath = os.path.join(self.element._filepath, self.layout_name + ".usda") rop.parm("lopoutput").set(self.savePath) rop.parm("enableoutputprocessor_simplerelativepaths").set(0) # save to disk rop.parm("execute").pressButton() #add attributes to stage reqired for proper unpacking later self.create_attributes(out) # publish :) self.comment = qd.HoudiniInput(parent=hou.qt.mainWindow(), title="Comment for publish?") self.comment.submitted.connect(self.layout_comment)
def build_network(self, path): animNode = hou.node("/obj").createNode("cenoteAnimation") animNode.setName(self.asset_name + "_anim", 1) animNode.parm("fileName").set(path) animNode.parm("scale").set(0.01) animNode.parm("buildHierarchy").pressButton() #animNode.parm("rendersubd").set(True) matPath = self.getMatPath() hdaPath = matPath.split(".")[0] + ".hda" if os.path.exists(hdaPath): hou.hda.installFile(hdaPath) for child in hou.node("/mat").children(): if child.type().name() == re.sub(r'\W+', '', self.asset_name): child.destroy() newMat = hou.node("/mat").createNode( re.sub(r'\W+', '', self.asset_name)) newMat.setName(self.asset_name, 1) newMat.setMaterialFlag(True) animNode.parm("materialPath").set("/mat/" + newMat.name()) else: qd.error( "The material for " + self.asset_name + " needs to be republished before it can be cloned in. Republish the material and try again." )
def check_unsaved_changes(): unsaved_changes = mc.file(q=True, modified=True) if unsaved_changes: response = qd.yes_or_no("Would you like to publish the current asset before you proceed?", title="Unsaved changes detected", details="(Press No if you just created a new scene or opened Maya.)") if response is True: # instead of saving, publish. scene = mc.file(q=True, sceneName=True) dir_path = scene.split("assets/") try: asset_path = dir_path[1].split("/") except: # scene path is stored in the user directory instead of assets. We can't get the asset name, so they must publish manually. qd.error("Publish failed. Please publish manually before cloning the new asset.") return asset_name = asset_path[0] try: department = asset_path[1].split("/")[0] print("department " + department) except: department = None if department: print("department found") else: qd.warning("Skipping changes to " + str(asset_name)) return publisher = Publisher(quick_publish=True, export=False) publisher.non_gui_publish(asset_name, department)
def results(self, value): print("Selected shot: " + value[0]) shot_name = value[0] self.body = Project().get_body(shot_name) self.element = self.body.get_element(Asset.HIP) if self.element.get_last_version() >= 0: #check if checked out if self.element.is_assigned(): assigned_user = self.element.get_assigned_user() username = Environment().get_user().get_username() if not assigned_user == username: qd.error("This shot is currently checked out by " + assigned_user) return else: username = Environment().get_user().get_username() self.element.update_assigned_user(username) path = self.element.get_last_publish()[3] if path: hou.hipFile.load(path) else: qd.error("Nothing was cloned")
def results(self, value): name = value[0] body = self.project.get_sequence(name) element = body.get_element(Asset.LIGHTS) if element.get_last_version() < 0: qd.error("Nothing has been published for this tool") return filepath = element.get_last_publish()[3] hou.hda.installFile(filepath) #stage = hou.node("/stage") try: hda = hou.node("/obj").createNode("sequence_"+name+"_lights") except Exception as e: #qd.error("Couldn't create node of type " + name + ". You should still be able to tab in the node manually.") print(e) return try: hda.setName(name+"_sequence_lights", 1) except: pass try: hda.allowEditOfContents() except: pass
def results(self, value): self.asset_name = value[0] body = Project().get_asset(self.asset_name) if not body: body = self.project.create_asset(self.asset_name) if not body: qd.error("Something broke :'(") return self.element = body.get_element(Asset.USD) self.path = os.path.join(self.element._filepath, "temp.usda") selection = hou.selectedNodes() if len(selection) != 1: qd.error("Please select the last node in the network and try again.") return out = selection[0] rop = hou.node("/stage").createNode("usd_rop") rop.setInput(0, out) rop.parm("lopoutput").set(self.path) rop.parm("enableoutputprocessor_simplerelativepaths").set(0) rop.parm("execute").pressButton() rop.destroy() publishes = self.element.list_publishes() publishes_string_list = "" for publish in publishes: label = publish[0] + " " + publish[1] + " " + publish[2] + "\n" publishes_string_list += label self.input = qd.HoudiniInput(parent=hou.qt.mainWindow(), title="Comment ", info=publishes_string_list) self.input.submitted.connect(self.comment_results)
def solaris_asset_results(self, value): self.asset_name = value[0] body = Project().get_asset(self.asset_name) if not body: body = Project().create_asset(self.asset_name) if not body: qd.error("Something broke :'(") return self.element = body.get_element(Asset.USD) self.path = os.path.join(self.element._filepath, "temp.usda") selection = hou.selectedNodes() if len(selection) != 1: qd.error( "Please select the last node in the network and try again.") return out = selection[0] rop = hou.node("/stage").createNode("usd_rop") rop.setInput(0, out) rop.parm("lopoutput").set(self.path) rop.parm("enableoutputprocessor_simplerelativepaths").set(0) rop.parm("execute").pressButton()
def results(self, value): self.layout_name = value[0] self.layout = self.project.get_layout(self.layout_name) if self.layout is None: self.layout = Project().create_layout(self.layout_name) if self.layout is None: qd.error("Stephanie done messed up") return self.element = self.layout.get_element(Asset.LAYOUT) rop = hou.node("/stage").createNode("usd_rop") out = hou.selectedNodes()[0] rop.setInput(0, out) self.savePath = os.path.join(self.element._filepath, self.layout_name + ".usda") rop.parm("lopoutput").set(self.savePath) rop.parm("enableoutputprocessor_simplerelativepaths").set(0) rop.parm("execute").pressButton() rop.destroy() publishes = self.element.list_publishes() publishes_string_list = "" for publish in publishes: label = publish[0] + " " + publish[1] + " " + publish[2] + "\n" publishes_string_list += label self.comment = qd.HoudiniInput( parent=hou.qt.mainWindow(), title="Comment for publish?", info=publishes_string_list) self.comment.submitted.connect(self.comment_results)
def publish(self): if len(hou.selectedNodes()) != 1: qd.error("Select only the last node in the network") return layout_list = Project().list_layouts() self.item_gui = sfl.SelectFromList(l=layout_list, parent=hou.qt.mainWindow(), title="Which layout are you publishing?") self.item_gui.submitted.connect(self.results)
def asset_results(self, value): self.asset_name = value[0] element = self.shot.get_element( os.path.join(Asset.ANIMATION, self.asset_name)) if element.get_last_version < 0: qd.error("There are no publishes for this asset in this shot.") return path = element.get_last_publish()[3] self.build_network(path)
def build_asset(self, main_name, variants): stage = hou.node("/stage") self.primpath = "/" + main_name prim = stage.createNode("primitive") prim.setName("base_prim", 1) prim.parm("primpath").set(self.primpath) config = stage.createNode("configurelayer") config.setName("set_default_prim", 1) config.setInput(0, prim) config.parm("defaultprim").set(self.primpath) config.parm("setdefaultprim").set(1) add_var = stage.createNode("addvariant") add_var.parm("primpath").set(self.primpath) in_count = 1 for var in variants: self.add_variant(var, config, add_var, in_count) in_count += 1 out_label = stage.createNode("null") out_label.setName(main_name + "_OUT", 1) out_label.setInput(0, add_var) #our asset is now assembled, and just needs to be published body = self.project.get_asset(main_name) if not body: qd.error("Error publishing asset " + main_name + ". Continuing to next asset.") return element = body.get_element(Asset.USD) element.update_app_ext(".usda") path = os.path.join(element._filepath, "temp.usda") rop = hou.node("/stage").createNode("usd_rop") rop.setInput(0, out_label) rop.parm("lopoutput").set(path) rop.parm("enableoutputprocessor_simplerelativepaths").set(0) rop.parm("execute").pressButton() stage.layoutChildren() comment = "Automatic publish" username = "******" name = main_name element.publish(username, path, comment, name) for child in stage.children(): child.destroy()
def open_scene_file(self, selected_scene_file): if selected_scene_file is not None: if not os.path.exists(selected_scene_file): qd.error( "That publish is missing. It may have been deleted to clear up space." ) return False else: if self.type == Asset.RIG or self.type == Asset.ANIMATION or self.type == Asset.CAMERA: # reference in the file mc.file(selected_scene_file, r=True, ignoreVersion=True, mnc=False, gl=True, ns=":") print("File referenced: " + selected_scene_file) elif self.type == Asset.GEO: # check for import vs reference im = qd.binary_option( "Do you want to import or reference this asset?", "Import", "Reference") if im: # import the geometry mc.file(selected_scene_file, i=True, ignoreVersion=True, mnc=False, gl=True, ns=":") print("File imported: " + selected_scene_file) else: # reference the geometry mc.file(selected_scene_file, r=True, ignoreVersion=True, mnc=False, gl=True, ns=":") print("File referenced: " + selected_scene_file) else: # reference the file mc.file(selected_scene_file, r=True, ignoreVersion=True, mnc=False, gl=True, ns=":") print("File referenced: " + selected_scene_file) return True else: return False
def results(self, value): print("Final value: ", value[0]) filename = value[0] self.namespace = filename if self.type == Asset.GEO or self.type == Asset.RIG: body = self.project.get_body(filename) self.body = body element = self.body.get_element(self.type) else: self.body = self.shot element = self.body.get_element(os.path.join(self.type, filename)) if element is None: qd.warning("Nothing was cloned.") return self.element = element if self.quick: latest = element.get_last_publish() if not latest: qd.error("There have been no publishes in this department.") return else: selected_scene_file = latest[3] #if we're cloning a model, lets make sure we're getting the obj instead of the usda if self.type == Asset.GEO: path = selected_scene_file.split(".") selected_scene_file = path[0] + ".obj" self.open_scene_file(selected_scene_file) return self.publishes = element.list_publishes() print("publishes: ", self.publishes) if not self.publishes: qd.error("There have been no publishes in this department.") return # make the list a list of strings, not tuples self.sanitized_publish_list = [] for publish in self.publishes: label = publish[0] + " " + publish[1] + " " + publish[2] self.sanitized_publish_list.append(label) self.item_gui = sfl.SelectFromList(l=self.sanitized_publish_list, parent=maya_main_window(), title="Select publish to clone") self.item_gui.submitted.connect(self.publish_selection_results)
def checkFileName(name): from pipe.pipeHandlers import quick_dialogs as qd if not re.match('^[a-zA-Z][a-zA-Z0-9.]*', name): qd.error( "AssetName can't start with a number or symbol!\nAlso, AssetName can only have letters, numbers and \'.\'\'s" ) return False first_char_to_lower = lambda s: s[:1].lower() + s[1:] if s else '' name = first_char_to_lower(name) '''if name.find('_') != -1: qd.error("AssetName can't have underscore!") return False''' if name.find('/') != -1: qd.error("AssetName can't have backslash!") return False if name.find('!') != -1: qd.error("AssetName can't have Exclamation point!") return False if name.find('|') != -1: qd.error("AssetName can't have pipe (|)!") return False return True
def camera_results(self, value): camera_name = value[0] element = self.shot.get_element(os.path.join(Asset.CAMERA, camera_name)) if element.get_last_version < 0: qd.error("There are no publishes for this camera.") return path = element.get_last_publish()[3] cameraNode = hou.node("/obj").createNode("cenoteCamera") cameraNode.setName(self.shot_name + "_camera", 1) cameraNode.parm("fileName").set(path) cameraNode.parm("scale").set(0.01) cameraNode.parm("buildHierarchy").pressButton()
def type_results(self, value): self.type = value[0] print(self.type) if self.type == "Model": self.clone_geo() elif self.type == "Rig": self.clone_rig() elif self.type == "Animation": self.clone_anim() elif self.type == "Camera": self.clone_camera() else: qd.error("Stephanie did something wrong, go complain to her :)") return
def open_scene_file(self, selected_scene_file): if selected_scene_file is not None: if not os.path.exists(selected_scene_file): qd.error( "That publish is missing. It may have been deleted to clear up space.") return False else: # do the thing command = "mayaUsd_createStageFromFilePath(\"" + selected_scene_file + "\")" pm.Mel.eval(command) return True else: return False
def results(self, value): print("Selected asset: " + value[0]) filename = value[0] self.body = Project().get_body(filename) self.element = self.body.get_element(Asset.USD) if self.element: path = self.element.get_last_publish()[3] if path: ref = hou.node("/stage").createNode("reference") ref.setName(filename + "_ref", 1) ref.parm("filepath1").set(path) ref.parm("primpath").set("/layout/" + filename) else: qd.error("Nothing was cloned")
def shot_results(self, value): shot_name = value[0] shot = self.project.get_shot(shot_name) if shot is None: qd.error("There was a problem loading the shot.") return prevNum = shot.get_camera_number() newNum = prevNum + 1 shot.set_camera_number(newNum) message = "There are now " + str( newNum) + " cameras in shot " + shot_name qd.message(message)
def results(self, value): name = value[0] body = self.project.get_tool(name) element = body.get_element(Asset.HDA) if element.get_last_version() < 0: qd.error("Nothing has been published for this tool") return filepath = element.get_last_publish()[3] panes = self.getCurrentNetworkEditorPane() paths = [] for pane in panes: paths.append(pane.pwd()) try: hou.hda.uninstallFile(filepath) hou.hda.installFile(filepath) #print("no problem here") except Exception as e: print(e) return hda = None for p in paths: try: print(p) hda = p.createNode(name) break except Exception as e: #qd.error("Couldn't create node of type " + name + ". You should still be able to tab in the node manually.") print(e) #return if not hda: qd.error("Couldn't create node of type " + name + ". You should still be able to tab in the node manually.") try: hda.setName(name, 1) except: pass try: hda.allowEditOfContents() except: pass
def asset_results(self, value): self.fileName = value[0] selection = hou.selectedNodes() # If it is more than one or none, abort if len(selection) != 1: qd.error( 'Please select a single Houdini Digital Asset node to save and update version on.' ) return # If it is not a Houdini Digital Asset, abort if not selection[0].type().definition(): qd.error( 'Please select a single Houdini Digital Asset node to save and update version on.' ) return #add code to force node name/node type name hda_node = selection[0] definition = hda_node.type().definition() libraryFilePath = definition.libraryFilePath() self.filepath = libraryFilePath '''current_full_name = hda_node.type().name() # last index is current version current_version_string = hda_node.type().nameComponents()[-1] #current_major = current_version_string.split('.')[0] #print('major version is ' + current_major) #current_minor = current_version_string.split('.')[1] # Set the 3 digit revision number to 0 if the HDA is only using the single float versioning (1.0 and not 1.0.005) current_revision = 0 if len(current_version_string.split( '.')) < 3 else current_version_string.split('.')[2] all_definitions = hou.hda.definitionsInFile(libraryFilePath) # This sets the node to the latest version of those stored hda_node.changeNodeType(all_definitions[-1].nodeTypeName())''' definition.updateFromNode(hda_node) self.body = Project().create_asset(self.fileName) if self.body is None: self.body = Project().get_asset(self.fileName) if self.body is None: print("Stephanie did an oopsie whoopsie :'(") return self.input = qd.HoudiniInput(parent=hou.qt.mainWindow(), title="Comment ") self.input.submitted.connect(self.comment_results)
def get_camera(self): if self.camElement.get_last_version < 0: qd.error( "There is no camera for this shot, so it cannot be built. Quitting build for shot " + self.shot_name + "...") return False try: path = self.camElement.get_last_publish()[3] cameraNode = hou.node("/obj").createNode("cenoteCamera") cameraNode.setName(self.shot_name + "_camera", 1) cameraNode.parm("fileName").set(path) cameraNode.parm("scale").set(0.01) cameraNode.parm("buildHierarchy").pressButton() return True except Exception as e: print(e) return False
def assignMats(self, layout, matDict, matList, library): layout.parm("num_materials").set(len(matDict.keys())) index = 1 for mat in matDict.keys(): if re.sub(r'\W+', '', mat) in matList: #this material is already up to date matNode = hou.node(library.path() + "/" + mat) else: #clone in that material's hda to the network asset = self.project.get_asset(mat) if not asset: print("Well there's your problem :/") continue element = asset.get_element(Asset.MATERIALS) matNode = None if element.get_last_version() >= 0: path = element.get_last_publish()[3] hdaPath = path.split(".")[0] + ".hda" try: hou.hda.installFile(hdaPath) matNode = library.createNode(re.sub(r'\W+', '', mat)) matNode.setName(mat, 1) matNode.setMaterialFlag(True) except Exception as e: qd.error( "The material for " + mat + " needs to be republished. Sorry for the inconvenience." ) #print(e) #assign the material to all the paths layout.parm("group" + str(index)).set(matDict[mat]) if matNode: layout.parm("shop_materialpath" + str(index)).set( matNode.path()) index += 1