def __init__(self): self.asset_gui = None # The order in which these nodes appear is the order they will be created in self.dcc_geo_departments = [Department.MODIFY, Department.MATERIAL] self.dcc_character_departments = [Department.HAIR, Department.CLOTH] self.all_departments = [ Department.MODIFY, Department.MATERIAL, Department.HAIR, Department.CLOTH ] # The source HDA's are currently stored inside the pipe source code. self.hda_path = Environment().get_otl_dir() # We define the template HDAs definitions here, for use in the methods below self.hda_definitions = { Department.MATERIAL: hou.hdaDefinition(hou.sopNodeTypeCategory(), "dcc_material", os.path.join(self.hda_path, "dcc_material.hda")), Department.MODIFY: hou.hdaDefinition(hou.sopNodeTypeCategory(), "dcc_modify", os.path.join(self.hda_path, "dcc_modify.hda")), Department.HAIR: hou.hdaDefinition(hou.objNodeTypeCategory(), "dcc_hair", os.path.join(self.hda_path, "dcc_hair.hda")), Department.CLOTH: hou.hdaDefinition(hou.objNodeTypeCategory(), "dcc_cloth", os.path.join(self.hda_path, "dcc_cloth.hda")) } # By default, we ignore "Asset Controls", so that we can put things in there without them being promoted. # See: inherit_parameters() method self.default_ignored_folders = ["Asset Controls"]
def get_definition_by_department(self, source_path): definition = None print("dept: ", self.department) if self.department == Department.MATERIAL: definition = hou.hdaDefinition(hou.sopNodeTypeCategory(), "dcc_material", source_path) elif self.department == Department.MODIFY: definition = hou.hdaDefinition(hou.sopNodeTypeCategory(), "dcc_modify", source_path) elif self.department == Department.HAIR: definition = hou.hdaDefinition(hou.objNodeTypeCategory(), "dcc_hair", source_path) elif self.department == Department.CLOTH: definition = hou.hdaDefinition(hou.objNodeTypeCategory(), "dcc_cloth", source_path) return definition
def findNodeByType(context, pattern): import fnmatch nodeTypeCategories = {} nodeTypeCategories['Object'] = hou.objNodeTypeCategory() nodeTypeCategories['Sop'] = hou.sopNodeTypeCategory() nodeTypeCategories['Vop'] = hou.vopNodeTypeCategory() nodeTypeCategories['Dop'] = hou.dopNodeTypeCategory() nodeTypeCategories['Cop2'] = hou.cop2NodeTypeCategory() nodeTypeCategories['Chop'] = hou.chopNodeTypeCategory() nodeTypeCategories['Shop'] = hou.shopNodeTypeCategory() nodeTypeCategories['Driver'] = hou.ropNodeTypeCategory() nodeTypeCategories['Top'] = hou.topNodeTypeCategory() nodeTypeCategories['Lop'] = hou.lopNodeTypeCategory() category = nodeTypeCategories[context] nodes = [ nodetype for nodetypename, nodetype in category.nodeTypes().items() if fnmatch.fnmatch(nodetypename, pattern) ] if nodes: return nodes[0] else: return None
def test_typeSetDefaultIcon(self): nodeType = hou.nodeType(hou.objNodeTypeCategory(), "geo") nodeType.setIcon("SOP_box") nodeType.setDefaultIcon() self.assertEqual(nodeType.icon(), "OBJ_geo")
def create_new_hda_definition(self, element, asset_name, department, checkout_file, content_hda_filepath=None): # CREATE NEW HDA DEFINITION if content_hda_filepath is None: content_hda_filepath = checkout_file print("content hda filepath: ", content_hda_filepath) operator_name = str(element.get_parent() + "_" + element.get_department()) operator_label = str((asset_name.replace("_", " ") + " " + element.get_department()).title()) self.hda_definitions[department].copyToHDAFile(checkout_file, operator_name, operator_label) hda_type = hou.objNodeTypeCategory( ) if department in self.dcc_character_departments else hou.sopNodeTypeCategory( ) hou.hda.installFile(content_hda_filepath) print("hda type: ", hda_type) print("operator_name: ", operator_name) print("content_hda_filepath : ", content_hda_filepath) hda_definition = hou.hdaDefinition(hda_type, operator_name, content_hda_filepath) try: hda_definition.setPreferred(True) except: print("hda definition was not created")
def published_definition(self, asset_name, department): # Set the node type correctly category = hou.objNodeTypeCategory( ) if department in self.dcc_character_departments else hou.sopNodeTypeCategory( ) hou.hda.reloadAllFiles() # Get the HDA File Path hda_name = asset_name + "_" + department hda_file = hda_name + "_main.hdanc" new_hda_path = os.path.join(Project().get_project_dir(), "production", "hda", hda_file) old_hda_path = os.path.join(Project().get_project_dir(), "production", "otls", hda_file) hda_path = "" # Does it exist? if os.path.islink(new_hda_path): hda_path = os.readlink(new_hda_path) elif os.path.islink(old_hda_path): hda_path = os.readlink(old_hda_path) else: return False # If it does, grab the definition hou.hda.installFile(hda_path) hda_definition = hou.hdaDefinition(category, hda_name, hda_path) # If the definition failed for some reason, don't tab it in. if hda_definition is not None: hda_definition.setPreferred(True) return True else: return False
def high_repair(is_full=False): preprocess() # High Frequency Pass matcher = nodesearch.Name(HDA_name) for node in matcher.nodes(hou.node("/obj/"), recursive=True): if hou.node(node.path() + "/hf_prepare_3d"): node_3d = hou.node(node.path() + "/hf_prepare_3d") if hou.node(node.path() + "/hf_optimize_3d"): node_op_3d = hou.node(node.path() + "/hf_optimize_3d") if hou.node(node.path() + "/hf_prepare_2d"): node_2d = hou.node(node.path() + "/hf_prepare_2d") ''' 1. Choose 3D Context Region ''' node_3d.bypass(False) ''' 2-4. 3D Context Region Optimization ''' node_op_3d.bypass(False) ''' 5. Generate 2D Render ''' num_images = len( glob.glob(hou.hipFile.name().split(".")[0] + "/*_opening.png")) mark_for_destroy = [] image_paths = [] cameras = hou.nodeType(hou.objNodeTypeCategory(), "cam").instances() for camera in cameras: camera_name = camera.name() if "oz_camera_" in camera_name and int(filter( str.isdigit, camera_name)) > num_images: mark_for_destroy.append(camera) renders = hou.nodeType(hou.ropNodeTypeCategory(), "ifd").instances() for render in renders: render_name = render.name() if "oz_render_" in render_name: if int(filter(str.isdigit, render_name)) <= num_images: image_paths.append(render.parm("vm_picture").eval()) render.render() else: mark_for_destroy.append(render) ''' 6. Map 3D Region -> 2D Render 7. 2D Repair ''' #render_then_map(image_paths, node_2d) render_map_thread = Thread(target=render_then_map, args=( image_paths, node_2d, is_full, )) render_map_thread.start() ''' *. Clean-Up ''' for node in mark_for_destroy: node.destroy() reset_camera_info()
def loadContents(network, ctx, type_ctx, filename): if type_ctx == hou.objNodeTypeCategory(): hdaAsset(network, ctx, filename) if type_ctx == hou.objNodeTypeCategory(): objGeom(network, ctx, filename) if type_ctx == hou.sopNodeTypeCategory(): sopGeom(network, ctx, filename) if type_ctx == hou.vopNodeTypeCategory(): shopImages(network, ctx, filename) if type_ctx == hou.chopNodeTypeCategory(): chanFiles(network, ctx, filename) if type_ctx == hou.cop2NodeTypeCategory(): copImages(network, ctx, filename)
def list_cameras(self): """ Return a list of tuple representing the Houdini cameras. Each tuple contains a camera node and its name. """ cameras = [] cam_nodes = hou.nodeType(hou.objNodeTypeCategory(), "cam").instances() for cam_node in cam_nodes: cameras.append((cam_node.name(), cam_node)) return cameras
def create_materials(self): """Iterates over all selected Nodes and applies a Material""" # With No Selection just create a Material Node if not self.nodes: m = rs_mat.RSMat() m.create_material() # Setup OpenGL Shaders o = ogl.rsOGL() o.link(m.get_material_builder()) self.count += 1 # Check if Called Via RightClickMenu if isinstance(self.nodes, Iterable): for n in self.nodes: # Check against OBJ-Level Nodes and Subnets if n.type().category() != hou.objNodeTypeCategory(): break if not n.isSubNetwork(): m = rs_mat.RSMat(self.context, n.name(), None) m.create_material() n.parm("shop_materialpath").set(m.get_path()) # Setup OpenGL Shaders o = ogl.rsOGL() o.link(m.get_material_builder()) self.count += 1 else: # For Calling Via Right Click Menu if self.nodes.type().category() != hou.objNodeTypeCategory(): return if not self.nodes.isSubNetwork(): m = rs_mat.RSMat(self.context, self.nodes.name(), None) m.create_material() self.nodes.parm("shop_materialpath").set(m.get_path()) # Setup OpenGL Shaders o = ogl.rsOGL() o.link(m.get_material_builder()) self.count += 1 self.display_message()
def createViewerStateTemplate(): state_name = "qLib::camera_zoom_vertigo_ql_obj" state_label = "Camera Zoom/Vertigo (obj) [qL]" template = hou.ViewerStateTemplate( state_name, state_label, hou.objNodeTypeCategory(), #contexts = [ hou.sopNodeTypeCategory(), hou.dopNodeTypeCategory(), hou.lopNodeTypeCategory(), ], ) template.bindFactory(qLibCameraZoomVertigo.State) return template
def reloadAllAlembics(): sop_node_type=hou.sopNodeTypeCategory().nodeTypes()['alembic'] obj_node_type=hou.objNodeTypeCategory().nodeTypes()['alembicarchive'] for child in hou.node('/obj/').children(): if child.type() == obj_node_type: child.parm('buildHierarchy').pressButton() else: for sopChild in child.allSubChildren(): if child.type() == sop_node_type: child.parm('reload').pressButton()
def reconstruct_node(): save_spare = 0 nodes = hou.selectedNodes() for node in nodes: if node.type().category()==hou.objNodeTypeCategory(): code = ["orig_node = hou.node(\"" + node.path() + "\")\nparent = orig_node.parent()"] i = 0 for parm in node.parms(): if i < 2: # if save_spare==parm.isSpare() or (save_spare==1 and parm.isSpare()==0): # code.append(parm.asCode()) i+=1 code.insert(1, "\norig_node.destroy()" + "\nnode=parent.createNode(\"" + node.type().name() + "\", \"" + node.name() + "\")") code.insert(2, "\nnode.")
def return_cameras(self): """ Returns any cameras that are in the hierarchy :param string abc_file_path: :return: """ cameras = list() for child in self.archive.allSubChildren(): if child.type() == hou.objNodeTypeCategory().nodeTypes()["cam"]: cameras.append(child) return cameras
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) selectedNodes = [] for node in hou.selectedNodes(): if node.type().category() == hou.sopNodeTypeCategory(): selectedNodes.append(node) elif node.type().category() == hou.objNodeTypeCategory(): if selectedNodes: qd.error( "Selected nodes for asset must be inside a geo node or a single geo node." ) selectedNodes = node.children() break if body == None: qd.error("Asset with name " + name + " already exists in pipeline.") elif self.type == AssetType.SHOT: qd.info("Shot created successfully.", "Success") else: assembler = Assembler() HDA = assembler.create_hda(name, body=body, selected_nodes=selectedNodes) HDA.type().definition().updateFromNode(HDA) #HDA.updateFromNode(HDA) qd.info("Asset created successfully.", "Success") else: qd.error("Asset creation failed.")
f.write(message) f.flush() # DEBUGGING END # I set this sucker up as a singleton. It's a matter of preference. this = sys.modules[__name__] # The source HDA's are currently stored inside the pipe source code. hda_path = os.path.join(Environment().get_project_dir(), "byu-pipeline-tools", "houdini-tools", "otls") # We define the template HDAs definitions here, for use in the methods below hda_definitions = { Department.MATERIAL: hou.hdaDefinition(hou.sopNodeTypeCategory(), "byu_material", os.path.join(hda_path, "byu_material.hda")), Department.MODIFY: hou.hdaDefinition(hou.sopNodeTypeCategory(), "byu_modify", os.path.join(hda_path, "byu_modify.hda")), Department.HAIR: hou.hdaDefinition(hou.objNodeTypeCategory(), "byu_hair", os.path.join(hda_path, "byu_hair.hda")), Department.CLOTH: hou.hdaDefinition(hou.objNodeTypeCategory(), "byu_cloth", os.path.join(hda_path, "byu_cloth.hda")) } # The order in which these nodes appear is the order they will be created in byu_geo_departments = [Department.MODIFY, Department.MATERIAL] byu_character_departments = [Department.HAIR, Department.CLOTH] hda_dir = Environment().get_hda_dir() # Update mode types class UpdateModes: SMART = "smart" CLEAN = "clean" FROZEN = "frozen"
def create_node(type): nodes = hou.selectedNodes() connections = hou.selectedConnections() if nodes: if type == 'g' and nodes[0].type().category( ) == hou.objNodeTypeCategory(): type = 'geo' if type == 'g' and nodes[0].type().category( ) == hou.sopNodeTypeCategory(): type = 'groupcreate' if type == 'merge' or type == 'switch': # one node, multiple inputs node_create = nodes[0].parent().createNode(type) for node in nodes: node_create.setNextInput(node) node_create.moveToGoodPosition(relative_to_inputs=True, move_inputs=False, move_outputs=True, move_unconnected=False) if type == 'null' or type == 'xform' or type == 'attribwrangle' or type == 'geo' or type == 'blast' or type == 'groupcreate': # multiple nodes, one input for node in nodes: node_create = node.createOutputNode(type) node_create.moveToGoodPosition(relative_to_inputs=True, move_inputs=False, move_outputs=True, move_unconnected=False) # set current parm_pane = wf_selection.pane_linkGroup(hou.paneTabType.NetworkEditor) parm_pane.setCurrentNode(node_create) # set display # wf_network_parm.flag_display () if connections: if type == 'g' and connections[0].inputNode().type().category( ) == hou.objNodeTypeCategory(): type = 'geo' if type == 'g' and connections[0].inputNode().type().category( ) == hou.sopNodeTypeCategory(): type = 'groupcreate' for connection in connections: node_up = connection.inputNode() node_dn = connection.outputNode() node_up_index = connection.outputIndex() node_dn_index = connection.inputIndex() node_create = node_dn.createInputNode(node_dn_index, type) node_create.setNextInput(node_up, node_up_index) node_create.moveToGoodPosition(relative_to_inputs=False, move_inputs=False, move_outputs=True, move_unconnected=False) # set current parm_pane = wf_selection.pane_linkGroup(hou.paneTabType.NetworkEditor) parm_pane.setCurrentNode(node_create)
def importDataFromXmlToAbc(): # select Alembic archive # abc = lastSelectedNode() if abc is None: hou.ui.setStatusMessage("Select one root Alembic Archive node.") hou.ui.displayMessage( "No root Alembic Archive node has been selected. Select one.", title="Attention, monsieur!") return None if abc.type() == hou.nodeType(hou.objNodeTypeCategory(), 'alembicarchive'): print "Alembic Archive found" else: print "No Alembic Archive selected" # XML stuff # #file_name = "/home/max/exported_data.xml" hou.ui.setStatusMessage("Choose XML file to import textures from.") file_name = hou.ui.selectFile(start_directory="/mnt/karramba/", title="Choose XML", pattern="*.xml") if file_name == "": return None file_name = os.path.expandvars(file_name) xml = parse(file_name) xmlobjects = xml.getElementsByTagName("object") # parse and assign textures # stat_assigned = 0 stat_noshader = 0 stat_newshader = 0 i = 0 for obj in xmlobjects: object_name = obj.getElementsByTagName("object_name")[0] object_path = object_name.childNodes[0].data #print object_path object_path = object_path.replace('|', '/') print object_path object_fullpath = abc.path() + object_path print object_fullpath #get texture data from XML object_texture_color = obj.getElementsByTagName("texture_color")[0] texture_path_color = object_texture_color.childNodes[0].data object_texture_spec = obj.getElementsByTagName("texture_spec")[0] texture_path_spec = object_texture_spec.childNodes[0].data object_texture_bump = obj.getElementsByTagName("texture_bump")[0] texture_path_bump = object_texture_bump.childNodes[0].data #create shader if needed if hou.parm(str(object_fullpath) + "/shop_materialpath") is None: shader_template = hou.galleries.galleryEntries("mantrasurface")[0] shader[i] = shader_template.createChildNode(hou.node("shop")) shader[i].setName(object_name) stat_newshader = stat_newshader + 1 if hou.parm(str(object_fullpath) + "/shop_materialpath") is not None: object_shader = hou.parm( str(object_fullpath) + "/shop_materialpath").evalAsString() #object_shader = hou.node(str(object_fullpath)).evalParm("shop_materialpath") if hou.node(object_shader) is not None: if hou.node(object_shader).parm("baseColorMap") is not None: hou.node(object_shader).parm("baseColorMap").set( str(texture_path_color)) if hou.node(object_shader).parm("baseSpecMap") is not None: hou.node(object_shader).parm("baseSpecMap").set( str(texture_path_spec)) if hou.node(object_shader).parm("baseDispMap") is not None: hou.node(object_shader).parm("baseDispMap").set( str(texture_path_bump)) stat_assigned = stat_assigned + 1 else: print object_fullpath + ": Shader assigned, but doesn't exist." stat_noshader = stat_noshader + 1 i += 1 print str(stat_assigned) + " textures assigned successfully." print str(stat_newshader) + " shaders created." print str(stat_noshader) + " shaders assigned, but not found."
def get_embedded_img_hdadef(): category = hou.objNodeTypeCategory() embedded = 'Embedded' hda_def = hou.hdaDefinition(category, embedded_hda_typename(), embedded) return hda_def
def test_typeIsNotSubnet(self): nodeType = hou.nodeType(hou.objNodeTypeCategory(), "geo") self.assertFalse(nodeType.isSubnetType())
def test_typeIsSubnet(self): nodeType = hou.nodeType(hou.objNodeTypeCategory(), "subnet") self.assertTrue(nodeType.isSubnetType())
def scan_scene(self): """ The scan scene method is executed once at startup and its purpose is to analyze the current scene and return a list of references that are to be potentially operated on. The return data structure is a list of dictionaries. Each scene reference that is returned should be represented by a dictionary with three keys: - "node": The name of the 'node' that is to be operated on. Most DCCs have a concept of a node, path or some other way to address a particular object in the scene. - "type": The object type that this is. This is later passed to the update method so that it knows how to handle the object. - "path": Path on disk to the referenced object. Toolkit will scan the list of items, see if any of the objects matches any templates and try to determine if there is a more recent version available. Any such versions are then displayed in the UI as out of date. """ items = [] # get a list of all regular alembic nodes in the file alembic_nodes = hou.nodeType(hou.objNodeTypeCategory(), "alembicarchive").instances() # return an item for each alembic node found. the breakdown app will check # the paths of each looking for a template match and a newer version. for alembic_node in alembic_nodes: file_parm = alembic_node.parm("fileName") file_path = os.path.normpath(file_parm.eval()) items.append({ "node": alembic_node.path(), "type": "alembic", "path": file_path, }) # get a list of all regular file nodes in the file file_nodes = hou.nodeType(hou.sopNodeTypeCategory(), "file").instances() for file_node in file_nodes: file_parm = file_node.parm("file") file_path = os.path.normpath(file_parm.eval()) items.append({ "node": file_node.path(), "type": "file", "path": file_path, }) cam_nodes = hou.nodeType(hou.objNodeTypeCategory(), "cam").instances() for cam_node in cam_nodes: file_parm = cam_node.parm("vm_background") file_path = os.path.normpath(file_parm.eval()) items.append({ "node": cam_node.path(), "type": "cam", "path": file_path, }) return items
def importDataFromXmlToAbc(): # select Alembic archive # abc = lastSelectedNode() if abc is None: hou.ui.setStatusMessage("Select one root Alembic Archive node.") hou.ui.displayMessage( "No root Alembic Archive node has been selected. Select one.", title="Attention, monsieur!") return None if abc.type() == hou.nodeType(hou.objNodeTypeCategory(), 'alembicarchive'): print "Alembic Archive found" else: print "No Alembic Archive selected" # XML stuff # #file_name = "/home/max/exported_data.xml" hou.ui.setStatusMessage("Choose XML file to import textures from.") file_name = hou.ui.selectFile(start_directory="/mnt/karramba/", title="Choose XML", pattern="*.xml") if file_name == "": return None file_name = os.path.expandvars(file_name) xml = parse(file_name) xmlobjects = xml.getElementsByTagName("object") # parse and assign textures # stat_assigned = 0 stat_noshader = 0 for obj in xmlobjects: object_name = obj.getElementsByTagName("object_name")[0] object_path = object_name.childNodes[0].data print object_path object_path = object_path.replace('|', '/') print object_path object_fullpath = abc.path() + object_path print object_fullpath object_texture_color = obj.getElementsByTagName("texture_color")[0] texture_path_color = object_texture_color.childNodes[0].data object_texture_spec = obj.getElementsByTagName("texture_spec")[0] texture_path_spec = object_texture_spec.childNodes[0].data object_texture_bump = obj.getElementsByTagName("texture_bump")[0] texture_path_bump = object_texture_bump.childNodes[0].data if hou.parm(str(object_fullpath) + "/shop_materialpath") is not None: object_shader = hou.parm( str(object_fullpath) + "/shop_materialpath").evalAsString() #object_shader = hou.node(str(object_fullpath)).evalParm("shop_materialpath") if hou.node(object_shader) is not None: hou.node(object_shader).parm("baseColorMap").set( str(texture_path_color)) # if hou.node(object_shader).parm("baseSpecMap") is not None: # hou.node(object_shader).parm("baseSpecMap").set(str(texture_path_color)) # else: # continue # if hou.node(object_shader).parm("baseDispMap") is not None: # hou.node(object_shader).parm("baseDispMap").set(str(texture_path_bump)) # else: # continue stat_assigned = stat_assigned + 1 else: print object_fullpath + ": No shader found. Could not assign the texture." stat_noshader = stat_noshader + 1 else: #print "Could not find assigned shader on " + object_fullpath continue print str(stat_assigned) + " textures assigned successfully." print str(stat_noshader) + " destination shaders not found."
def camImport(): node = hou.pwd() clearKeys(node) file = node.parm("json").eval() if os.path.isfile(file): jsonData = open(file, "r") camData = json.load(jsonData) res = camData[1]["resolution"] fr = camData[1]["frames"] pos = camData[1]["camPos"] look = camData[1]["camCentInt"] up = camData[1]["camUpVector"] focal = camData[1]["camFocal"] aperture = camData[1]["camAperture"] clip = camData[1]["camClip"] fdist = camData[1]["camFocusDistance"] fstop = camData[1]["camFStop"] mblur = camData[1]["motionBlurBy"] p_dist = camData[1]["p_distance"] p_rad = camData[1]["p_radius"] camType = "stereocamrig" paralax = camData[1]["camStereoParallax"] ditance = camData[1]["camStereoDistance"] if not paralax: camType = "cam" origin = node.node("origin") lookat = node.node("lookat") cams = [None, None, None] for child in node.children(): if child.type() == hou.nodeType(hou.objNodeTypeCategory(), "cam") and child.name() == 'cam': cams[0] = child if child.type() == hou.nodeType(hou.objNodeTypeCategory(), "cam") and child.name() == 'persp': cams[1] = child if child.type() == hou.nodeType(hou.objNodeTypeCategory(), "stereocamrig"): cams[2] = child for cam in cams: cam.parm("resx").set(res[0]) cam.parm("resy").set(res[1]) cam.parm("shutter").set(mblur[0] * 0.4) cam.parm("lookatpath").set("../lookat") lens = cam.node('./shopnet1/miDOF_lens') if lens: cam.parm('projection').set(4) cam.parm('vm_lensshader').set('./shopnet1/miDOF_lens') iter = 0 for frame in fr: objSetKey(cam.parm("upx"), frame, up[iter][0]) objSetKey(cam.parm("upy"), frame, up[iter][1]) objSetKey(cam.parm("upz"), frame, up[iter][2]) objSetKey(cam.parm("focal"), frame, focal[iter]) objSetKey(cam.parm("aperture"), frame, aperture[iter][0] * 25.4) objSetKey(cam.parm("near"), frame, clip[iter][0]) objSetKey(cam.parm("far"), frame, clip[iter][1]) objSetKey(cam.parm("focus"), frame, fdist[iter]) objSetKey(cam.parm("fstop"), frame, fstop[iter]) if lens: objSetKey(lens.parm("focus"), frame, p_dist[iter]) objSetKey(lens.parm("radius"), frame, p_rad[iter]) if camType == "stereocamrig" and cam == cams[1]: objSetKey(cam.parm("ZPS"), frame, paralax[iter]) objSetKey(cam.parm("interaxial"), frame, ditance[iter]) iter += 1 cams[2].parm("lookatpath").set("../lookat_stereo") iter = 0 for frame in fr: objSetKey(origin.parm("tx"), frame, pos[iter][0]) objSetKey(origin.parm("ty"), frame, pos[iter][1]) objSetKey(origin.parm("tz"), frame, pos[iter][2]) objSetKey(lookat.parm("tx"), frame, look[iter][0]) objSetKey(lookat.parm("ty"), frame, look[iter][1]) objSetKey(lookat.parm("tz"), frame, look[iter][2]) iter += 1
import hou #Set DefaultShape & Color Redshift Lights hou.nodeType(hou.objNodeTypeCategory(), "rslight").setDefaultColor(hou.Color(1, 1, 0)) hou.nodeType(hou.objNodeTypeCategory(), "rslight").setDefaultShape('light') hou.nodeType(hou.objNodeTypeCategory(), "rslighties").setDefaultColor(hou.Color(1, 1, 0)) hou.nodeType(hou.objNodeTypeCategory(), "rslighties").setDefaultShape('light') hou.nodeType(hou.objNodeTypeCategory(), "rslightportal").setDefaultColor(hou.Color(1, 1, 0)) hou.nodeType(hou.objNodeTypeCategory(), "rslightportal").setDefaultShape('light') hou.nodeType(hou.objNodeTypeCategory(), "rslightsun").setDefaultColor(hou.Color(1, 1, 0)) hou.nodeType(hou.objNodeTypeCategory(), "rslightsun").setDefaultShape('light') hou.nodeType(hou.objNodeTypeCategory(), "rslightdome::2.0").setDefaultColor(hou.Color(1, 1, 0)) hou.nodeType(hou.objNodeTypeCategory(), "rslightdome::2.0").setDefaultShape('light')
def paste_clipboard_to_netview(kwargs): """Paste clipboard contents (text or image) into the network editor. """ clipboard = Qt.QtGui.QGuiApplication.clipboard() image = clipboard.image() text = clipboard.text() pane = kwargs.get('editor', None) if pane: pwd = pane.pwd() if image.isNull(): # paste text (if any) if text != "": note = pwd.createStickyNote() note.move(pane.visibleBounds().center()) s = note.size() s = hou.Vector2(( s.x() * 1.5, s.y() * 0.5, )) note.setText(text) note.setSize(s) else: # paste image # TODO: generate automatic name image_name = '' ok, image_name = hou.ui.readInput( 'Enter name of image to be pasted:', buttons=( 'Ok', 'Cancel', ), close_choice=1, initial_contents=image_name) if image_name == '': ok = 1 image_name += '.png' if ok == 0: category = hou.objNodeTypeCategory() hda_typename = 'qLib::embedded_images' embedded = 'Embedded' hda_def = hou.hdaDefinition(category, hda_typename, embedded) # create hda definition if doesn't exist if not hda_def: temp_node = hou.node('/obj').createNode('subnet') hda_node = temp_node.createDigitalAsset( name=hda_typename, save_as_embedded=True) hda_node.destroy() hda_def = hou.hdaDefinition(category, hda_typename, embedded) # create an instance in /obj if doesn't exist node = None nodes = [ n for n in hou.node('/obj').children() if n.type().name() == hda_typename ] if len(nodes) == 0: node = hou.node('/obj').createNode( hda_typename, node_name="embedded_images") # add clipboard image to hda definition (as section) ba = Qt.QtCore.QByteArray() buffer = Qt.QtCore.QBuffer(ba) buffer.open(Qt.QtCore.QIODevice.WriteOnly) image.save(buffer, "png") buffer.close() hda_def.addSection(image_name, str(buffer.data())) # add image to network view image = hou.NetworkImage( "opdef:/qLib::Object/embedded_images?%s" % image_name) image.setBrightness(0.75) #image.setRect(hou.BoundingRect(0, 0, 5, 2)) s = pane.visibleBounds() center = s.center() s.translate(-center) s.scale(( 0.25, 0.25, )) s.translate(center) image.setRect(s) images = nodegraphutils.loadBackgroundImages(pwd) images.append(image) pane.setBackgroundImages(images) nodegraphutils.saveBackgroundImages(pwd, images)
def create_hda(asset_name, department, already_tabbed_in_node=None): # Check if this body is an asset. If not, return error. body = Project().get_body(asset_name) if not body.is_asset(): error_message("Must be an asset of type PROP or CHARACTER.") return None # Check if it is a set. if body.get_type() == AssetType.SET: error_message("Asset must be a PROP or CHARACTER.") return None # Check if the user is trying to create a Hair or Cloth asset for a Prop on accident. if body.get_type() == AssetType.PROP and (department == Department.HAIR or department == Department.CLOTH): error_message("Hair and cloth should only be made for characters.") return None # Create element if does not exist. element = body.get_element(department, name=Element.DEFAULT_NAME, force_create=True) # TODO: Get rid of this ugly hotfix # !!! HOTFIX !!! # Material was previously used as an AssetElement, but now is being treated like an HDAElement. # This will convert it's file extension to .hdanc. (Before, it's extension was ""). element._datadict[Element.APP_EXT] = element.create_new_dict(Element.DEFAULT_NAME, department, asset_name)[Element.APP_EXT] element._update_pipeline_file() # !!! END HOTFIX !!! # Check out the department. username = Project().get_current_username() checkout_file = element.checkout(username) # Tab in the parent asset that will hold this checked out HDA node = already_tabbed_in_node if already_tabbed_in_node else tab_in(hou.node("/obj"), asset_name, excluded_departments=[department]) # If it's a character and it's not a hair or cloth asset, we need to reach one level deeper. if body.get_type() == AssetType.CHARACTER and department not in this.byu_character_departments: inside = node.node("inside/geo/inside") else: inside = node.node("inside") # CREATE NEW HDA DEFINITION operator_name = element.get_parent() + "_" + element.get_department() operator_label = (asset_name.replace("_", " ") + " " + element.get_department()).title() this.hda_definitions[department].copyToHDAFile(checkout_file, operator_name, operator_label) hda_type = hou.objNodeTypeCategory() if department in this.byu_character_departments else hou.sopNodeTypeCategory() hou.hda.installFile(checkout_file) hda_definition = hou.hdaDefinition(hda_type, operator_name, checkout_file) hda_definition.setPreferred(True) # Tab an instance of this new HDA into the asset you are working on try: hda_instance = inside.createNode(asset_name + "_" + department) print('noce') except Exception as e: error_message("HDA Creation Error. " + asset_name + "_" + department + " must not exist.") hda_instance.setName(department) tab_into_correct_place(inside, hda_instance, department) hda_instance.allowEditingOfContents() hda_instance.setSelected(True, clear_all_selected=True) return hda_instance