Python hou.Node() Examples

The following are 30 code examples of hou.Node(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module hou , or try the search function .
Example #1
Source File: pipeline.py    From core with MIT License 6 votes vote down vote up
def parse_container(container):
    """Return the container node's full container data.

    Args:
        container (hou.Node): A container node name.

    Returns:
        dict: The container schema data for this container node.

    """
    data = lib.read(container)

    # Backwards compatibility pre-schemas for containers
    data["schema"] = data.get("schema", "avalon-core:container-1.0")

    # Append transient data
    data["objectName"] = container.path()
    data["node"] = container

    return data 
Example #2
Source File: tools.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def get_config_parameter_list(farm_name, rop_node):
    """
    Retrieves the parameter layout for a particular farm integration and a particular node.

    Args:
        farm_name (str): Name of the farm integration. Lowercase. Must match the name of the farm module. E.g. "deadline"
        rop_node (hou.Node): A ROP node (in any context)

    Returns:
        List: A list of parameter definitions
    """

    parm_list = get_node_parameter_list(farm_name, rop_node)
    if parm_list is None:
        return None
    include_dict = get_include_config_dict(farm_name)
    nodes_dict = get_nodes_config_dict(farm_name)
    return expand_json_include_blocks(nodes_dict, parm_list, include_dict) 
Example #3
Source File: tools.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def get_node_folder_type_name(rop_node):
    """
    Used to get a readable name for a ROP node. Used for the top level folder name. Currently only used on IFD
    Rops to call their top level folders "Mantra" instead of "Ifd"
    
    Args:
        rop_node (hou.Node): A ROP node (in any context) to provide the name for

    Returns:
        String: The readable name
    """
    folder_name = rop_node.type().name().title()

    regex = re.compile(r"((?P<company>[a-zA-Z.]*)::)?(?P<name>[a-zA-z_]+)(::(?P<version>[a-zA-Z0-9._]*))?")
    matches = regex.match(folder_name)
    if matches is not None:
        folder_name = matches.group("name")

    # Special cases for nodes where their type name is not a good folder label
    folder_name_dict = {"Ifd": "Mantra", 
                        "Baketexture": "Bake Texture"}
    if folder_name in folder_name_dict:
        folder_name = folder_name_dict[folder_name]

    return folder_name 
Example #4
Source File: tools.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def unpatch_rop(script_args, farm_name, rop_node, error_list_obj=None):
    """
    Undos the patching operation on a ROP. Removes the custom farm folder and parameters and moves the original
    parameters back up to the top level.

    Args:
        script_args (dict): The Houdini "kwargs" dictionary
        farm_name (str): Name of the farm integration. Lowercase. Must match the name of the farm module. E.g. "deadline"
        rop_node (hou.Node): A ROP node (in any context) to unpatch
        error_list_obj (RopErrorList): An instance of RopErrorList class to store any errors or warnings

    Returns:
        Bool: True if successfully removed, False if not
    """
    with ErrorList(error_list_obj) as error_list_obj:

        if remove_top_level_folders(rop_node, "hf_orig_parms", [farm_name.title()]) is False:
            error_list_obj.add(WarningMessage("Failed to un-patch: {0}".format(rop_node.path())))
            return False
        return True 
Example #5
Source File: tools.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def patch_rop(script_args, farm_name, rop_node, error_list_obj=None):
    """
    Patches a ROP with spare parameters to allow for farm submission. Puts existing parameters underneath a
    top level folder, and patches it with the required farm parameter folder which contains parameters for submission.

    Args:
        script_args (dict): The Houdini "kwargs" dictionary
        farm_name (str): Name of the farm integration. Lowercase. Must match the name of the farm module. E.g. "deadline"
        rop_node (hou.Node): A ROP node (in any context) to patch
        error_list_obj (RopErrorList): An instance of RopErrorList class to store any errors or warnings

    Returns:
        Bool: True on success, otherwise False
    """
    with ErrorList(error_list_obj) as error_list_obj:

        if not is_rop_patchable(farm_name, rop_node):
            error_list_obj.add(WarningMessage("ROP nodes of type '{0}' not supported ".format(rop_node.type().name())))
            return False

        prepare_rop_for_new_parms(rop_node)
        create_rop_parameters(script_args, farm_name, rop_node, error_list_obj)
        return True 
Example #6
Source File: auxiliary.py    From anima with MIT License 6 votes vote down vote up
def create_spare_input(node, value=''):
    """creates spare inputs for the given node and sets the value

    :param hou.Node node: The node to insert the spare input to.
    :param str value: The value of the parameter
    """
    # Create space input0 for rs proxy output node
    parm_template_group = node.parmTemplateGroup()
    parm_template_group.append(
        hou.StringParmTemplate(
            'spare_input0', 'Spare Input 0', 1,
            string_type=hou.stringParmType.NodeReference
        )
    )
    node.setParmTemplateGroup(parm_template_group)
    node.parm('spare_input0').set(value) 
Example #7
Source File: tools.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def set_config_parameter_list(farm_name, json_dict, rop_node, parameter_list):
    """
    Sets parameter data for a specified node and farm.

    Args:
        farm_name (str): Name of the farm integration. Lowercase. Must match the name of the farm module. E.g. "deadline"
        json_dict (dict): Hierarchical dictionary of values
        rop_node (hou.Node): A ROP node (in any context)
        parameter_list (list): Parameter list

    Returns:
        None
    """
    node_context = get_rop_context_name()
    node_type = rop_node.type().name()

    set_dict_path(json_dict, ["farm", farm_name, "nodes", node_context, node_type], parameter_list) 
Example #8
Source File: soptoolutils.py    From CNCGToolKit with MIT License 6 votes vote down vote up
def genericTool(scriptargs, nodetypename, nodename = None,
                isreusable = False, iscapture = False, allow_obj_sel=True,
                custom=False, merge_context=False, orient=None,
                exact_node_type = True,
                force_filter = False):
    """ Invokes a generic SOP tool.
        If isreusable is True, then the tool will try to reuse existing
        nodes of matching type in the network before creating any new nodes.
        If iscapture is True, then the tool is considered to be a capture-type
        tool.  Capture-type tools will attempt to create new nodes before
        any deform-type SOPs in the network.
        If merge_context is True, then we create the generator in context,
        while merging it together with the current display sop.
        If orient is set, it should be an instance of OrientInfo.
        If exact_node_type is True, it creates the node of the exact type 
        specified by nodetypename.  However, if exact_node_type is False, 
        then the base type may get resolved to another namespace or 
        another version, and the created node may be of that resolved type 
        (eg 'hda' may resolve to 'mynamespace::hda::2.0').
        If force_Filter is True, we will treat as a filter even if
        it can optionally have no inputs.
    """
    return hou.Node() 
Example #9
Source File: soptoolutils.py    From NukeToolSet with MIT License 6 votes vote down vote up
def genericTool(scriptargs, nodetypename, nodename = None,
                isreusable = False, iscapture = False, allow_obj_sel=True,
                custom=False, merge_context=False, orient=None,
                exact_node_type = True,
                force_filter = False):
    """ Invokes a generic SOP tool.
        If isreusable is True, then the tool will try to reuse existing
        nodes of matching type in the network before creating any new nodes.
        If iscapture is True, then the tool is considered to be a capture-type
        tool.  Capture-type tools will attempt to create new nodes before
        any deform-type SOPs in the network.
        If merge_context is True, then we create the generator in context,
        while merging it together with the current display sop.
        If orient is set, it should be an instance of OrientInfo.
        If exact_node_type is True, it creates the node of the exact type 
        specified by nodetypename.  However, if exact_node_type is False, 
        then the base type may get resolved to another namespace or 
        another version, and the created node may be of that resolved type 
        (eg 'hda' may resolve to 'mynamespace::hda::2.0').
        If force_Filter is True, we will treat as a filter even if
        it can optionally have no inputs.
    """
    return hou.Node() 
Example #10
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def createSopNodeContainer(sceneviewer, newobjectname, merge_context = False,
                           merge_creator = None):
    """ Creates a scene level object node to contain a new SOP node.
        This function may return an existing object node if the Model in
        Context option is turned on, or the merge_context parameter is
        set to True.
    """
    return hou.Node() 
Example #11
Source File: ShapeComponent.py    From gamestuff with GNU Lesser General Public License v3.0 5 votes vote down vote up
def getHouNode(self):
		'''
		gets the visual representation - hou.Node
		please, dont destroy the node or do anything inappropriate with it
		moving it also wont work, cuz this component rewrites it's position and shape every update
		'''
		return self.__mynode 
Example #12
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def genericTool(scriptargs, nodetypename, nodename=None, nodetypecategory=None,
                exact_node_type=True):
    """ Handles the creation of any node in a Network Editor pane. 

        This function is intended to instantiate a node of a given type from
        shelf tools, and thus, if exact_node_type argument is True, it creates 
        the node of the exact type specified by nodetypename. 
        However, if exact_node_type argument is False, then the base type may 
        get resolved to another namespace or another version, and 
        the created node may be of that resolved type (eg 'hda' may resolve to 
        'mynamespace::hda::2.0').
    """
    return hou.Node() 
Example #13
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def createNodeInContainer(container, nodetypecategory, nodetypename, nodename,
                          exact_node_type):
    """This function attempts to create a node of a given type category and
       type name in a given container. If the container does not allow a given 
       type category, this funciton creates a network of a correct type first,
       and then creates the required node within that network.
       If exact_node_type is true, it attempts to create a node of the exact
       nodetypename; otherwise, the nodtypename may be resolved to the
       preferred namespace or version of that typename.
       It retuns a pair of nodes, the fist being the node created in the
       container and the second being the node of a required operator type
       (which in most cases will be the same nodes).
    """
    return (hou.Node(),hou.Node()) 
Example #14
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def _askUserToSelectNode(nodes, title, message):
    return hou.Node() 
Example #15
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findAncestorOfType(startnode, category, nodetype, basetypematch=False):
    """ Return closest ancestor (or self) of 'startnode' with the specified
        category and type.
    """
    return hou.Node() 
Example #16
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findAllChildNodesOfType(parentnode, nodetype, dorecurse=False, basetypematch=False):
    """ Returns a list of all child nodes that match the given node
        type
    """
    return hou.Node() 
Example #17
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findDeformTypeInputSop(endnode):
    """ This function does a depth first traversal of the node
        input hierarchy to find the first deform-type node.
        Returns the deform-type node.  Returns None if no such node exists.
    """
    return hou.Node() 
Example #18
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def getGeometrySelections(sceneviewer, selectors, allow_obj_selection=True,
                          prompt = None):
    """ This function invokes a geometry selection for each
        selector in "selectors".  The selector is not started, but
        its properties are used when calling sceneviewer.selectGeometry().
    """
    return (None,[], hou.Node()) 
Example #19
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findOutputNodeOfTypeWithParms(startnode, nodetype, parmlist, 
                                includeme=False, seennodes=None,
                                basetypematch=False, returnall=False):
    """ Finds any nodes that are a descendent of startnode, match
        nodetype, and have the parameters & value pairs listed in the
        parmlist dictionary.
        If basetypematch is true, only the node type's base name is checked, 
        ie, node type's namespace and version components are ignored
        when testing against the matchtype (eg, matchtype 'hda' will match
        node types 'hda', 'hda::1.5' and 'userx::hda', etc). Otherwise,
        the node type name must match exactly the matchtype string.
        If returnall is true, returns a list of all matches in depth
        first order, or an empty list if no matches are found.
    """
    return hou.Node() 
Example #20
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def createSopNodeFilter(container, nodetypename, nodename, exact_node_type):
    """ Creates a SOP node that takes an input. """
    # Look at the type of nodes that go inside the current node.
    return hou.Node() 
Example #21
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def createSopNodeGenerator(container, nodetypename, nodename,
                           merge_context = False,
                           exact_node_type = True):
    """ Creates a SOP node that doesn't require an input. If the container
        already has nodes, this new SOP may be merged with the existing SOPs.
    """
    # Look at the type of nodes that go inside the current node.
    return hou.Node() 
Example #22
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def genericSopNodeFilterTool(scriptargs, nodetypename, nodename,
                             isreusable=False, iscapture=False,
                             allow_obj_sel=True, selector_indices=(),
                             exact_node_type=True):
    """ A generic tool for creating a SOP node that takes another SOP node
        as input. The user is prompted for selections based on the selector
        bindings set in the OPbindings file.
    """
    return hou.Node() 
Example #23
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findChildNodeOfType(parentnode, nodetype, dorecurse=False, basetypematch=False):
    """ This function does a search of the node container hierarchy
        (rather than connection hierarchy) searching for a matching
        node type.
    """
    return hou.Node() 
Example #24
Source File: soptoolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def buildPaintNode(node, nextnode, parms, props):
    """ Finds a paint node at or prior to node which matches parms.
        If not found, builds one.  If the attribute does not exist,
        creates the attribute to paint.
        It will be inserted prior to nextnode if not none.
    """
    return hou.Node() 
Example #25
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findInputNodeOfTypeWithParms(endnode, nodetype, parmlist, 
                                includeme=False, seennodes=None,
                                basetypematch=False):
    """Finds any nodes that are an ancestor of endnode, match
        nodetype, and have the parameters & value pairs listed in the
        parmlist dictionary.
        If basetypematch is true, only the node type's base name is checked, 
        ie, node type's namespace and version components are ignored
        when testing against the matchtype (eg, matchtype 'hda' will match
        node types 'hda', 'hda::1.5' and 'userx::hda', etc). Otherwise,
        the node type name must match exactly the matchtype string.
    """

    return hou.Node() 
Example #26
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findGreatestCommonDescendent(endnode, searchnodes, seennodes=None):
    """ Starting from end node and heading up the input chain
        locate the first node that doesn't have all of searchnodes
        on the same input wire.
    """
    return hou.Node() 
Example #27
Source File: toolutils.py    From CNCGToolKit with MIT License 5 votes vote down vote up
def findChildNodeOfTypeWithParms(parentnode, nodetype, parmlist,
                                 dorecurse=False, basetypematch=False):
    """ This function does a search of the node container hierarchy
        (rather than connection hierarchy) searching for a matching
        node type which also has the given parameter list match.
    """
    return hou.Node() 
Example #28
Source File: toolutils.py    From NukeToolSet with MIT License 5 votes vote down vote up
def findInputNodeOfTypeWithParms(endnode, nodetype, parmlist, 
                                includeme=False, seennodes=None,
                                basetypematch=False):
    """Finds any nodes that are an ancestor of endnode, match
        nodetype, and have the parameters & value pairs listed in the
        parmlist dictionary.
        If basetypematch is true, only the node type's base name is checked, 
        ie, node type's namespace and version components are ignored
        when testing against the matchtype (eg, matchtype 'hda' will match
        node types 'hda', 'hda::1.5' and 'userx::hda', etc). Otherwise,
        the node type name must match exactly the matchtype string.
    """

    return hou.Node() 
Example #29
Source File: pipeline.py    From core with MIT License 5 votes vote down vote up
def process(self):
        """This is the base functionality to create instances in Houdini

        The selected nodes are stored in self to be used in an override method.
        This is currently necessary in order to support the multiple output
        types in Houdini which can only be rendered through their own node.

        Default node type if none is given is `geometry`

        It also makes it easier to apply custom settings per instance type

        Example of override method for Alembic:

            def process(self):
                instance =  super(CreateEpicNode, self, process()
                # Set paramaters for Alembic node
                instance.setParms(
                    {"sop_path": "$HIP/%s.abc" % self.nodes[0]}
                )

        Returns:
            hou.Node

        """

        if (self.options or {}).get("useSelection"):
            self.nodes = hou.selectedNodes()

        # Get the node type and remove it from the data, not needed
        node_type = self.data.pop("node_type", None)
        if node_type is None:
            node_type = "geometry"

        # Get out node
        out = hou.node("/out")
        instance = out.createNode(node_type, node_name=self.name)
        instance.moveToGoodPosition()

        lib.imprint(instance, self.data)

        return instance 
Example #30
Source File: lib.py    From core with MIT License 5 votes vote down vote up
def read(node):
    """Read the container data in to a dict

    Args:
        node(hou.Node): Houdini node

    Returns:
        dict

    """
    # `spareParms` returns a tuple of hou.Parm objects
    return {parameter.name(): parameter.eval() for
            parameter in node.spareParms()}