Operators

These are the available default operators in the NodeCalculator!

Attention

These operators must be accessed via the Op-class! For example:

import node_calculator.core as noca

node = noca.Node(“pCube1”)

noca.Op.decompose_matrix(node.worldMatrix)

Basic NodeCalculator operators.

base_operators._extension_operators_init()[source]

Fill EXTENSION_OPERATORS-dictionary with all available operations.

Note

EXTENSION_OPERATORS holds the data for each available operation: the necessary node-type, its inputs, outputs, etc. This unified data enables to abstract node creation, connection, ..

possible flags: - node: Type of Maya node necessary - inputs: input attributes (list of lists) - outputs: output attributes (list) - operation: set operation-attr for different modes of a node - output_is_predetermined: should always ALL output attrs be added?

Use “{array}” in inputs or outputs to denote an array-attribute!

base_operators.angle_between(vector_a, vector_b=(1, 0, 0))[source]

Create angleBetween-node to find the angle between 2 vectors.

Parameters:
  • vector_a (NcNode or NcAttrs or int or float or list) – Vector to consider for angle between.
  • vector_b (NcNode or NcAttrs or int or float or list or tuple) – Vector to consider for angle between. Defaults to (1, 0, 0).
Returns:

Instance with angleBetween-node and output-attribute(s)

Return type:

NcNode

Example

matrix = Node("pCube1").worldMatrix
pt = Op.point_matrix_mult(
    [1, 0, 0], matrix, vector_multiply=True
)
Op.angle_between(pt, [1, 0, 0])
base_operators.average(*attrs)[source]

Create plusMinusAverage-node for averaging input attrs.

Parameters:attrs (NcNode or NcAttrs or NcList or string or list or tuple) – Inputs to be averaged.
Returns:Instance with plusMinusAverage-node and output-attribute(s)
Return type:NcNode

Example

Op.average(Node("pCube.t"), [1, 2, 3])
base_operators.blend(attr_a, attr_b, blend_value=0.5)[source]

Create blendColor-node.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Plug or value to blend from
  • attr_b (NcNode or NcAttrs or str or int or float) – Plug or value to blend to
  • blend_value (NcNode or str or int or float) – Plug or value defining blend-amount. Defaults to 0.5.
Returns:

Instance with blend-node and output-attributes

Return type:

NcNode

Example

Op.blend(1, Node("pCube.tx"), Node("pCube.customBlendAttr"))
base_operators.choice(inputs, selector=0)[source]

Create choice-node to switch between various input attributes.

Note

Multi index input seems to also require one “selector” per index. So we package a copy of the same selector for each input.

Parameters:
  • inputs (NcList or NcAttrs or list) – Any number of input values or plugs
  • selector (NcNode or NcAttrs or int) – Selector-attr on choice node to select one of the inputs based on their index. Defaults to 0.
Returns:

Instance with choice-node and output-attribute(s)

Return type:

NcNode

Example

option_a = Node("pCube1.tx")
option_b = Node("pCube2.tx")
switch = Node("pSphere1").add_bool("optionSwitch")
choice_node = Op.choice([option_a, option_b], selector=switch)
Node("pTorus1").tx = choice_node
base_operators.clamp(attr_a, min_value=0, max_value=1)[source]

Create clamp-node.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Input value
  • min_value (NcNode or NcAttrs or int or float or list) – min-value for clamp-operation. Defaults to 0.
  • max_value (NcNode or NcAttrs or int or float or list) – max-value for clamp-operation. Defaults to 1.
Returns:

Instance with clamp-node and output-attribute(s)

Return type:

NcNode

Example

Op.clamp(Node("pCube.t"), [1, 2, 3], 5)
base_operators.closest_point_on_mesh(mesh, position=(0, 0, 0), return_all_outputs=False)[source]

Get the closest point on a mesh, from the given position.

Parameters:
  • mesh (NcNode or NcAttrs or str) – Mesh node.
  • position (NcNode or NcAttrs or int or float or list) – Find closest point on mesh to this position. Defaults to (0, 0, 0).
  • return_all_outputs (bool) – Return all outputs as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (position) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

cube = Node("pCube1")
Op.closest_point_on_mesh(cube.outMesh, [1, 0, 0])
base_operators.closest_point_on_surface(surface, position=(0, 0, 0), return_all_outputs=False)[source]

Get the closest point on a surface, from the given position.

Parameters:
  • surface (NcNode or NcAttrs or str) – NURBS surface node.
  • position (NcNode or NcAttrs or int or float or list) – Find closest point on surface to this position. Defaults to (0, 0, 0).
  • return_all_outputs (bool) – Return all outputs as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (position) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

sphere = Node("nurbsSphere1")
Op.closest_point_on_surface(sphere.local, [1, 0, 0])
base_operators.compose_matrix(translate=None, rotate=None, scale=None, shear=None, rotate_order=None, euler_rotation=None, **kwargs)[source]

Create composeMatrix-node to assemble matrix from transforms.

Parameters:
  • translate (NcNode or NcAttrs or str or int or float) – translate [t] Defaults to None, which corresponds to value 0.
  • rotate (NcNode or NcAttrs or str or int or float) – rotate [r] Defaults to None, which corresponds to value 0.
  • scale (NcNode or NcAttrs or str or int or float) – scale [s] Defaults to None, which corresponds to value 1.
  • shear (NcNode or NcAttrs or str or int or float) – shear [sh] Defaults to None, which corresponds to value 0.
  • rotate_order (NcNode or NcAttrs or str or int) – rot-order [ro] Defaults to None, which corresponds to value 0.
  • euler_rotation (NcNode or NcAttrs or bool) – Euler or quaternion [uer] Defaults to None, which corresponds to True.
  • kwargs (dict) – Short flags, see in [brackets] for each arg above. Long names take precedence!
Returns:

Instance with composeMatrix-node and output-attribute(s)

Return type:

NcNode

Example

in_a = Node("pCube1")
in_b = Node("pCube2")
decomp_a = Op.decompose_matrix(in_a.worldMatrix)
decomp_b = Op.decompose_matrix(in_b.worldMatrix)
Op.compose_matrix(r=decomp_a.outputRotate, s=decomp_b.outputScale)
base_operators.condition(condition_node, if_part=False, else_part=True)[source]

Set up condition-node.

Note

condition_node can be a NcNode-instance of a Maya condition node. An appropriate NcNode-object gets automatically created when NodeCalculator objects are used in comparisons (==, >, >=, <, <=). Simply use comparison operators in the first argument. See example.

Parameters:
  • condition_node (NcNode or bool or int or float) – Condition-statement. See note and example.
  • if_part (NcNode or NcAttrs or str or int or float) – Value/plug that is returned if the condition evaluates to true. Defaults to False.
  • else_part (NcNode or NcAttrs or str or int or float) – Value/plug that is returned if the condition evaluates to false. Defaults to True.
Returns:

Instance with condition-node and outColor-attributes

Return type:

NcNode

Example

condition_node = Node("pCube1.tx") >= 2
pass_on_if_true = Node("pCube2.ty") + 2
pass_on_if_false = 5 - Node("pCube2.tz").get()
# Op.condition(condition-part, "if true"-part, "if false"-part)
Op.condition(condition_node, pass_on_if_true, pass_on_if_false)
base_operators.cross(attr_a, attr_b=0, normalize=False)[source]

Create vectorProduct-node for vector cross-multiplication.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float or list) – Vector A.
  • attr_b (NcNode or NcAttrs or str or int or float or list) – Vector B. Defaults to 0.
  • normalize (NcNode or NcAttrs or bool) – Whether resulting vector should be normalized. Defaults to False.
Returns:

Instance with vectorProduct-node and output-attribute(s)

Return type:

NcNode

Example

Op.cross(Node("pCube.t"), [1, 2, 3], True)
base_operators.curve_info(curve)[source]

Measure the length of a curve.

Parameters:curve (NcNode, NcAttrs or string) – The curve to be measured.
Returns:Instance with vectorProduct-node and output-attribute(s)
Return type:NcNode

Example

Op.curve_info(Node("nurbsCurve.local"))
base_operators.decompose_matrix(in_matrix, return_all_outputs=False)[source]

Create decomposeMatrix-node to disassemble matrix into transforms.

Parameters:
  • in_matrix (NcNode or NcAttrs or string) – matrix attr to decompose
  • return_all_outputs (bool) – Return all outputs, as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (translate) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

driver = Node("pCube1")
driven = Node("pSphere1")
decomp = Op.decompose_matrix(driver.worldMatrix)
driven.t = decomp.outputTranslate
driven.r = decomp.outputRotate
driven.s = decomp.outputScale
base_operators.dot(attr_a, attr_b=0, normalize=False)[source]

Create vectorProduct-node for vector dot-multiplication.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float or list) – Vector A.
  • attr_b (NcNode or NcAttrs or str or int or float or list) – Vector B. Defaults to 0.
  • normalize (NcNode or NcAttrs or bool) – Whether resulting vector should be normalized. Defaults to False.
Returns:

Instance with vectorProduct-node and output-attribute(s)

Return type:

NcNode

Example

Op.dot(Node("pCube.t"), [1, 2, 3], True)
base_operators.euler_to_quat(angle, rotate_order=0)[source]

Create eulerToQuat-node to add two quaternions together.

Parameters:
  • angle (NcNode or NcAttrs or str or list or tuple) – Euler angles to convert into a quaternion.
  • rotate_order (NcNode or NcAttrs or or int) – Order of rotation. Defaults to 0, which represents rotate order “xyz”.
Returns:

Instance with eulerToQuat-node and output-attribute(s)

Return type:

NcNode

Example

Op.euler_to_quat(Node("pCube").rotate, 2)
base_operators.exp(attr_a)[source]

Raise attr_a to the base of natural logarithms.

Parameters:attr_a (NcNode or NcAttrs or str or int or float) – Value or attr
Returns:Instance with multiplyDivide-node and output-attr(s)
Return type:NcNode

Example

Op.exp(Node("pCube.t"))
base_operators.four_by_four_matrix(vector_a=None, vector_b=None, vector_c=None, translate=None)[source]

Create a four by four matrix out of its components.

Parameters:
  • vector_a (NcNode or NcAttrs or str or list or tuple or int or float) – First vector of the matrix; the “x-axis”. Or can contain all 16 elements that make up the 4x4 matrix. Defaults to None, which means the identity matrix will be used.
  • vector_b (NcNode or NcAttrs or str or list or tuple or int or float) – Second vector of the matrix; the “y-axis”. Defaults to None, which means the vector (0, 1, 0) will be used, if matrix is not defined solely by vector_a.
  • vector_c (NcNode or NcAttrs or str or list or tuple or int or float) – Third vector of the matrix; the “z-axis”. Defaults to None, which means the vector (0, 0, 1) will be used, if matrix is not defined solely by vector_a.
  • translate (NcNode or NcAttrs or str or list or tuple or int or float) – Translate-elements of the matrix. Defaults to None, which means the vector (0, 0, 0) will be used, if matrix is not defined solely by vector_a.
Returns:

Instance with fourByFourMatrix-node and output-attr(s)

Return type:

NcNode

Example

cube = Node("pCube1")
vec_a = Op.point_matrix_mult(
    [1, 0, 0],
    cube.worldMatrix,
    vector_multiply=True
)
vec_b = Op.point_matrix_mult(
    [0, 1, 0],
    cube.worldMatrix,
    vector_multiply=True
)
vec_c = Op.point_matrix_mult(
    [0, 0, 1],
    cube.worldMatrix,
    vector_multiply=True
)
out = Op.four_by_four_matrix(
    vector_a=vec_a,
    vector_b=vec_b,
    vector_c=vec_c,
    translate=[cube.tx, cube.ty, cube.tz]
)
base_operators.hold_matrix(matrix)[source]

Create holdMatrix-node for storing a matrix.

Parameters:matrix (NcNode or NcAttrs or string or list) – Matrix to store.
Returns:Instance with holdMatrix-node and output-attribute(s)
Return type:NcNode

Example

Op.hold_matrix(Node("pCube1.worldMatrix"))
base_operators.inverse_matrix(in_matrix)[source]

Create inverseMatrix-node to invert the given matrix.

Parameters:in_matrix (NcNode or NcAttrs or str) – Matrix to invert
Returns:Instance with inverseMatrix-node and output-attribute(s)
Return type:NcNode

Example

Op.inverse_matrix(Node("pCube.worldMatrix"))
base_operators.length(attr_a, attr_b=0)[source]

Create distanceBetween-node to measure length between given points.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Start point.
  • attr_b (NcNode or NcAttrs or str or int or float) – End point. Defaults to 0.
Returns:

Instance with distanceBetween-node and distance-attribute

Return type:

NcNode

Example

Op.len(Node("pCube.t"), [1, 2, 3])
base_operators.matrix_distance(matrix_a, matrix_b=None)[source]

Create distanceBetween-node to measure distance between matrices.

Parameters:
  • matrix_a (NcNode or NcAttrs or str) – Matrix defining start point.
  • matrix_b (NcNode or NcAttrs or str) – Matrix defining end point. Defaults to None, which gives the length between the origin and the point described by matrix_a.
Returns:

Instance with distanceBetween-node and distance-attribute

Return type:

NcNode

Example

Op.len(Node("pCube.worldMatrix"), Node("pCube2.worldMatrix"))
base_operators.mult_matrix(*attrs)[source]

Create multMatrix-node for multiplying matrices.

Parameters:attrs (NcNode or NcAttrs or NcList or string or list or tuple) – Matrices to multiply together.
Returns:Instance with multMatrix-node and output-attribute(s)
Return type:NcNode

Example

matrix_mult = Op.mult_matrix(
    Node("pCube1.worldMatrix"), Node("pCube2").worldMatrix
)
decomp = Op.decompose_matrix(matrix_mult)
out = Node("pSphere")
out.translate = decomp.outputTranslate
out.rotate = decomp.outputRotate
out.scale = decomp.outputScale
base_operators.nearest_point_on_curve(curve, position=(0, 0, 0), return_all_outputs=False)[source]

Get curve data from a particular point on a curve.

Parameters:
  • curve (NcNode or NcAttrs or str) – Curve node.
  • position (NcNode or NcAttrs or int or float or list) – Find closest point on curve to this position. Defaults to (0, 0, 0).
  • return_all_outputs (bool) – Return all outputs as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (position) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

curve = Node("curve1")
Op.nearest_point_on_curve(curve.local, [1, 0, 0])
base_operators.normalize_vector(in_vector, normalize=True)[source]

Create vectorProduct-node to normalize the given vector.

Parameters:
  • in_vector (NcNode or NcAttrs or str or int or float or list) – Vect.
  • normalize (NcNode or NcAttrs or bool) – Turn normalize on/off. Defaults to True.
Returns:

Instance with vectorProduct-node and output-attribute(s)

Return type:

NcNode

Example

Op.normalize_vector(Node("pCube.t"))
base_operators.pair_blend(translate_a=0, rotate_a=0, translate_b=0, rotate_b=0, weight=1, quat_interpolation=False, return_all_outputs=False)[source]

Create pairBlend-node to blend between two transforms.

Parameters:
  • translate_a (NcNode or NcAttrs or str or int or float or list) – Translate value of first transform. Defaults to 0.
  • rotate_a (NcNode or NcAttrs or str or int or float or list) – Rotate value of first transform. Defaults to 0.
  • translate_b (NcNode or NcAttrs or str or int or float or list) – Translate value of second transform. Defaults to 0.
  • rotate_b (NcNode or NcAttrs or str or int or float or list) – Rotate value of second transform. Defaults to 0.
  • weight (NcNode or NcAttrs or str or int or float or list) – Bias towards first or second transform. Defaults to 1.
  • quat_interpolation (NcNode or NcAttrs or bool) – Use euler (False) or quaternions (True) to interpolate rotation Defaults to False.
  • return_all_outputs (bool) – Return all outputs, as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (translate) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

a = Node("pCube1")
b = Node("pSphere1")
blend_attr = a.add_float("blend")
Op.pair_blend(a.t, a.r, b.t, b.r, blend_attr)
base_operators.pass_matrix(matrix, scale=1)[source]

Create passMatrix-node for passing and optionally scaling a matrix.

Parameters:
  • matrix (NcNode or NcAttrs or string or list) – Matrix to store.
  • scale (NcNode or NcAttrs or int or float) – Scale to be applied to matrix. Defaults to 1.
Returns:

Instance with passMatrix-node and output-attribute(s)

Return type:

NcNode

Example

Op.pass_matrix(Node("pCube1.worldMatrix"))
base_operators.point_matrix_mult(in_vector, in_matrix, vector_multiply=False)[source]

Create pointMatrixMult-node to transpose the given matrix.

Parameters:
  • in_vector (NcNode or NcAttrs or str or int or float or list) – Vect.
  • in_matrix (NcNode or NcAttrs or str) – Matrix
  • vector_multiply (NcNode or NcAttrs or str or int or bool) – Whether vector multiplication should be performed. Defaults to False.
Returns:

Instance with pointMatrixMult-node and output-attribute(s)

Return type:

NcNode

Example

Op.point_matrix_mult(
    Node("pSphere.t"),
    Node("pCube.worldMatrix"),
    vector_multiply=True
)
base_operators.point_on_curve_info(curve, parameter=0, as_percentage=False, return_all_outputs=False)[source]

Get curve data from a particular point on a curve.

Parameters:
  • curve (NcNode or NcAttrs or str) – Curve node.
  • parameter (NcNode or NcAttrs or int or float or list) – Get curve data at the position on the curve specified by this parameter. Defaults to 0.
  • as_percentage (NcNode or NcAttrs or int or float or bool) – Use 0-1 values for parameter. Defaults to False.
  • return_all_outputs (bool) – Return all outputs as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (position) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

curve = Node("curve1")
Op.point_on_curve_info(curve.local, 0.5)
base_operators.point_on_surface_info(surface, parameter=(0, 0), as_percentage=False, return_all_outputs=False)[source]

Get surface data from a particular point on a NURBS surface.

Parameters:
  • surface (NcNode or NcAttrs or str) – NURBS surface node.
  • parameter (NcNode or NcAttrs or int or float or list) – UV values that define point on NURBS surface. Defaults to (0, 0).
  • as_percentage (NcNode or NcAttrs or int or float or bool) – Use 0-1 values for parameters. Defaults to False.
  • return_all_outputs (bool) – Return all outputs as an NcList. Defaults to False.
Returns:

If return_all_outputs is set to True, an NcList is

returned with all outputs. Otherwise only the first output (position) is returned as an NcNode instance.

Return type:

NcNode or NcList

Example

sphere = Node("nurbsSphere1")
Op.point_on_surface_info(sphere.local, [0.5, 0.5])
base_operators.pow(attr_a, attr_b=2)[source]

Raise attr_a to the power of attr_b.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Value or attr.
  • attr_b (NcNode or NcAttrs or str or int or float) – Value or attr. Defaults to 2.
Returns:

Instance with multiplyDivide-node and output-attr(s)

Return type:

NcNode

Example

Op.pow(Node("pCube.t"), 2.5)
base_operators.quat_add(quat_a, quat_b=(0, 0, 0, 1))[source]

Create quatAdd-node to add two quaternions together.

Parameters:
  • quat_a (NcNode or NcAttrs or str or list or tuple) – First quaternion.
  • quat_b (NcNode or NcAttrs or str or list or tuple) – Second quaternion. Defaults to (0, 0, 0, 1).
Returns:

Instance with quatAdd-node and output-attribute(s)

Return type:

NcNode

Example

Op.quat_add(
    create_node("decomposeMatrix").outputQuat,
    create_node("decomposeMatrix").outputQuat,
)
base_operators.quat_conjugate(quat_a)[source]

Create quatConjugate-node to conjugate a quaternion.

Parameters:quat_a (NcNode or NcAttrs or str or list or tuple) – Quaternion to conjugate.
Returns:Instance with quatConjugate-node and output-attribute(s)
Return type:NcNode

Example

Op.quat_conjugate(create_node("decomposeMatrix").outputQuat)
base_operators.quat_invert(quat_a)[source]

Create quatInvert-node to invert a quaternion.

Parameters:quat_a (NcNode or NcAttrs or str or list or tuple) – Quaternion to invert.
Returns:Instance with quatInvert-node and output-attribute(s)
Return type:NcNode

Example

Op.quat_invert(create_node("decomposeMatrix").outputQuat)
base_operators.quat_mul(quat_a, quat_b=(0, 0, 0, 1))[source]

Create quatProd-node to multiply two quaternions together.

Parameters:
  • quat_a (NcNode or NcAttrs or str or list or tuple) – First quaternion.
  • quat_b (NcNode or NcAttrs or str or list or tuple) – Second quaternion. Defaults to (0, 0, 0, 1).
Returns:

Instance with quatProd-node and output-attribute(s)

Return type:

NcNode

Example

Op.quat_mul(
    create_node("decomposeMatrix").outputQuat,
    create_node("decomposeMatrix").outputQuat,
)
base_operators.quat_negate(quat_a)[source]

Create quatNegate-node to negate a quaternion.

Parameters:quat_a (NcNode or NcAttrs or str or list or tuple) – Quaternion to negate.
Returns:Instance with quatNegate-node and output-attribute(s)
Return type:NcNode

Example

Op.quat_negate(create_node("decomposeMatrix").outputQuat)
base_operators.quat_normalize(quat_a)[source]

Create quatNormalize-node to normalize a quaternion.

Parameters:quat_a (NcNode or NcAttrs or str or list or tuple) – Quaternion to normalize.
Returns:Instance with quatNormalize-node and output-attribute(s)
Return type:NcNode

Example

Op.quat_normalize(create_node("decomposeMatrix").outputQuat)
base_operators.quat_sub(quat_a, quat_b=(0, 0, 0, 1))[source]

Create quatSub-node to subtract two quaternions from each other.

Parameters:
  • quat_a (NcNode or NcAttrs or str or list or tuple) – First quaternion.
  • quat_b (NcNode or NcAttrs or str or list or tuple) – Second quaternion that will be subtracted from the first. Defaults to (0, 0, 0, 1).
Returns:

Instance with quatSub-node and output-attribute(s)

Return type:

NcNode

Example

Op.quat_sub(
    create_node("decomposeMatrix").outputQuat,
    create_node("decomposeMatrix").outputQuat,
)
base_operators.quat_to_euler(quat_a, rotate_order=0)[source]

Create quatToEuler-node to convert a quaternion into an euler angle.

Parameters:
  • quat_a (NcNode or NcAttrs or str or list or tuple) – Quaternion to convert into Euler angles.
  • rotate_order (NcNode or NcAttrs or or int) – Order of rotation. Defaults to 0, which represents rotate order “xyz”.
Returns:

Instance with quatToEuler-node and output-attribute(s)

Return type:

NcNode

Example

Op.quat_to_euler(create_node("decomposeMatrix").outputQuat, 2)
base_operators.remap_color(attr_a, output_min=0, output_max=1, input_min=0, input_max=1, values_red=None, values_green=None, values_blue=None)[source]

Create remapColor-node to remap the given input.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Input color.
  • output_min (NcNode or NcAttrs or int or float or list) – minValue. Defaults to 0.
  • output_max (NcNode or NcAttrs or int or float or list) – maxValue. Defaults to 1.
  • input_min (NcNode or NcAttrs or int or float or list) – old minValue. Defaults to 0.
  • input_max (NcNode or NcAttrs or int or float or list) – old maxValue. Defaults to 1.
  • values_red (list) – List of tuples for red-graph in the form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
  • values_green (list) – List of tuples for green-graph in the form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
  • values_blue (list) – List of tuples for blue-graph in the form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
Returns:

Instance with remapColor-node and output-attribute(s)

Return type:

NcNode

Raises:
  • TypeError – If given values isn’t a list of either lists or tuples.
  • RuntimeError – If given values isn’t a list of lists/tuples of length 2 or 3.

Example

Op.remap_color(
    Node("blinn1.outColor"),
    values_red=[(0.1, .2, 0), (0.4, 0.3)]
)
base_operators.remap_hsv(attr_a, output_min=0, output_max=1, input_min=0, input_max=1, values_hue=None, values_saturation=None, values_value=None)[source]

Create remapHsv-node to remap the given input.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Input color.
  • output_min (NcNode or NcAttrs or int or float or list) – minValue. Defaults to 0.
  • output_max (NcNode or NcAttrs or int or float or list) – maxValue. Defaults to 1.
  • input_min (NcNode or NcAttrs or int or float or list) – old minValue. Defaults to 0.
  • input_max (NcNode or NcAttrs or int or float or list) – old maxValue. Defaults to 1.
  • values_hue (list) – List of tuples for hue-graph in the form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
  • values_saturation (list) – List of tuples for saturation-graph in form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
  • values_value (list) – List of tuples for value-graph in the form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
Returns:

Instance with remapHsv-node and output-attribute(s)

Return type:

NcNode

Raises:
  • TypeError – If given values isn’t a list of either lists or tuples.
  • RuntimeError – If given values isn’t a list of lists/tuples of length 2 or 3.

Example

Op.remap_hsv(
    Node("blinn1.outColor"),
    values_saturation=[(0.1, .2, 0), (0.4, 0.3)]
)
base_operators.remap_value(attr_a, output_min=0, output_max=1, input_min=0, input_max=1, values=None)[source]

Create remapValue-node to remap the given input.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Input value
  • output_min (NcNode or NcAttrs or int or float or list) – minValue. Defaults to 0.
  • output_max (NcNode or NcAttrs or int or float or list) – maxValue. Defaults to 1.
  • input_min (NcNode or NcAttrs or int or float or list) – old minValue. Defaults to 0.
  • input_max (NcNode or NcAttrs or int or float or list) – old maxValue. Defaults to 1.
  • values (list) – List of tuples in the following form; (value_Position, value_FloatValue, value_Interp) The value interpolation element is optional (default: linear) Defaults to None.
Returns:

Instance with remapValue-node and output-attribute(s)

Return type:

NcNode

Raises:
  • TypeError – If given values isn’t a list of either lists or tuples.
  • RuntimeError – If given values isn’t a list of lists/tuples of length 2 or 3.

Example

Op.remap_value(
    Node("pCube.t"),
    values=[(0.1, .2, 0), (0.4, 0.3)]
)
base_operators.reverse(attr_a)[source]

Create reverse-node to get 1 minus the input.

Parameters:attr_a (NcNode or NcAttrs or str or int or float) – Input value
Returns:Instance with reverse-node and output-attribute(s)
Return type:NcNode

Example

Op.reverse(Node("pCube.visibility"))
base_operators.rgb_to_hsv(rgb_color)[source]

Create rgbToHsv-node to get RGB color in HSV representation.

Parameters:rgb_color (NcNode or NcAttrs or str or int or float) – Input RGB color.
Returns:Instance with rgbToHsv-node and output-attribute(s)
Return type:NcNode

Example

Op.rgb_to_hsv(Node("blinn1.outColor"))
base_operators.set_range(attr_a, min_value=0, max_value=1, old_min_value=0, old_max_value=1)[source]

Create setRange-node to remap the given input attr to a new min/max.

Parameters:
  • attr_a (NcNode or NcAttrs or str or int or float) – Input value.
  • min_value (NcNode or NcAttrs or int or float or list) – New min. Defaults to 0.
  • max_value (NcNode or NcAttrs or int or float or list) – New max. Defaults to 1.
  • old_min_value (NcNode or NcAttrs or int or float or list) – Old min. Defaults to 0.
  • old_max_value (NcNode or NcAttrs or int or float or list) – Old max. Defaults to 1.
Returns:

Instance with setRange-node and output-attribute(s)

Return type:

NcNode

Example

Op.set_range(Node("pCube.t"), [1, 2, 3], 4, [-1, 0, -2])
base_operators.sqrt(attr_a)[source]

Get the square root of attr_a.

Parameters:attr_a (NcNode or NcAttrs or str or int or float) – Value or attr
Returns:Instance with multiplyDivide-node and output-attr(s)
Return type:NcNode

Example

Op.sqrt(Node("pCube.tx"))
base_operators.sum(*attrs)[source]

Create plusMinusAverage-node for averaging input attrs.

Parameters:attrs (NcNode or NcAttrs or NcList or string or list or tuple) – Inputs to be added up.
Returns:Instance with plusMinusAverage-node and output-attribute(s)
Return type:NcNode

Example

Op.average(Node("pCube.t"), [1, 2, 3])
base_operators.transpose_matrix(in_matrix)[source]

Create transposeMatrix-node to transpose the given matrix.

Parameters:in_matrix (NcNode or NcAttrs or str) – Plug or value for in_matrix
Returns:Instance with transposeMatrix-node and output-attribute(s)
Return type:NcNode

Example

Op.transpose_matrix(Node("pCube.worldMatrix"))
base_operators.weighted_add_matrix(*matrices)[source]

Add matrices with a weight-bias.

Parameters:matrices (NcNode or NcAttrs or list or tuple) – Any number of matrices. Can be a list of tuples; (matrix, weight) or simply a list of matrices. In that case the weight will be evenly distributed between all given matrices.
Returns:Instance with wtAddMatrix-node and output-attribute(s)
Return type:NcNode

Example

::
cube_a = Node(“pCube1.worldMatrix”) cube_b = Node(“pCube2.worldMatrix”) Op.weighted_add_matrix(cube_a, cube_b)

Basic NodeCalculator functions.

base_functions.soft_approach(in_value, fade_in_range=0.5, target_value=1)[source]

Follow in_value, but approach the target_value slowly.

Note

Only works for 1D inputs!

Parameters:
  • in_value (NcNode or NcAttrs or str or int or float) – Value or attr
  • fade_in_range (NcNode or NcAttrs or str or int or float) – Value or attr. This defines a range over which the target_value will be approached. Before the in_value is within this range the output of this and the in_value will be equal. Defaults to 0.5.
  • target_value (NcNode or NcAttrs or str or int or float) – Value or attr. This is the value that will be approached slowly. Defaults to 1.
Returns:

Instance with node and output-attr.

Return type:

NcNode

Example

in_attr = Node("pCube.tx")
Op.soft_approach(in_attr, fade_in_range=2, target_value=5)
# Starting at the value 3 (because 5-2=3), the output of this
# will slowly approach the target_value 5.