Exemplo n.º 1
0
def makeControl():
    cwd = toolutils.sceneViewer().pwd()
    selected = [child for child in cwd.children() if child.isSelected()]
    if len(selected) == 0:
        raise hou.InvalidInput("need to select one Sop")
    node = selected[0]  # only work on first selected node

    # create node:
    nullNode = node.parent().createNode('null', node_name='CONTROL')
    nullNode.setColor(hou.Color((0, 0, 0)))
Exemplo n.º 2
0
def _copy_inputs(source_node, target_node):
    input_connections = source_node.inputConnections()
    num_target_inputs = len(target_node.inputConnectors())

    if len(input_connections) > num_target_inputs:
        raise hou.InvalidInput(
            "Not enough inputs on target node. Cannot copy inputs from "
            "'%s' to '%s'" % (source_node, target_node))

    for connection in input_connections:
        target_node.setInput(connection.inputIndex(), connection.inputNode())
Exemplo n.º 3
0
def makeOut():
    cwd = toolutils.sceneViewer().pwd()
    selected = [child for child in cwd.children() if child.isSelected()]
    if len(selected) == 0:
        raise hou.InvalidInput("need to select one Sop")
    node = selected[0]  # only work on first selected node
    #	node_type = node.type()
    #	if node_type.category().name() != 'Sop':
    #		raise hou.InvalidInput("only works on Sops")

    # create node:
    nullNode = node.parent().createNode('null', node_name='OUT')
    nullNode.setInput(0, node)
    nullNode.setColor(hou.Color((0, 0, 0)))
Exemplo n.º 4
0
def _copy_inputs(source_node, target_node):
    """Copy all the input connections from this node to the target node.

    :param hou.Node source_node: Soure node with inputs to copy.
    :param hou.Node target_node: Target node to receive the copied inputs.

    """

    input_connections = source_node.inputConnections()
    num_target_inputs = len(target_node.inputConnectors())

    if len(input_connections) > num_target_inputs:
        raise hou.InvalidInput(
            "Not enough inputs on target node. Cannot copy inputs from "
            "'%s' to '%s'" % (source_node, target_node))

    for connection in input_connections:
        target_node.setInput(connection.inputIndex(), connection.inputNode())
Exemplo n.º 5
0
    def _get_project(self):
        """Get the project name by looking up its ID.

        In case the current project is no longer in the list
        of projects, throw an error.
        """
        project_id = self._node.parm('project').eval()
        projects = data_block.for_houdini().projects()
        project_names = [project["name"]
                         for project in projects if project['id'] == project_id]
        if not project_names:
            raise hou.InvalidInput(
                "%s %s is an invalid project." %
                self._node.name(), project_id)
        return {
            "id": project_id,
            "name": project_names[0]
        }
Exemplo n.º 6
0
    def __copy_inputs_to_node(self, node, target, ignore_missing=False):
        """ Copy all the input connections from this node to the
            target node.

            ignore_missing: If the target node does not have enough
                            inputs then skip this connection.
        """
        input_connections = node.inputConnections()

        num_target_inputs = len(target.inputConnectors())
        if num_target_inputs is 0:
            raise hou.OperationFailed("Target node has no inputs.")

        for connection in input_connections:
            index = connection.inputIndex()
            if index > (num_target_inputs - 1):
                if ignore_missing:
                    continue
                else:
                    raise hou.InvalidInput("Target node has too few inputs.")

            target.setInput(index, connection.inputNode())
Exemplo n.º 7
0
def point_line_intersection(centroid, p1, p2):

    a = p2.position() - p1.position()
    centp1 = centroid - p1.position()
    betha = n.dot(a, centp1) / a.length()
    anorm = a.normalized()
    anorm *= betha
    dist = anorm.length()
    intersect = p1.position() + anorm
    return intersect, dist


try:
    get_curve = node.inputs()[1].geometry()
except IndexError:
    raise hou.InvalidInput("Need second Input")

# add color and distance attributes
clr_attr = geo.addAttrib(hou.attribType.Point, "Cd", (0, 1, 0))
dist_attr = geo.addAttrib(hou.attribType.Prim, "dist", -1)
# create the groups
line_grp = geo.createPrimGroup("lines")
base_grp = geo.createPrimGroup("base")

for pr in geo.prims():
    for vert in pr.vertices():
        vert.point().setAttribValue(clr_attr, (1, 1, 1))
    base_grp.add(pr)

curve_pts = get_curve.iterPoints()