openrig.maya.core.context module

Build context shared across the solution build pipeline.

Provides NamingStrategy (Protocol) and BuildContext, which carry the naming strategy, rigging conventions, and the in-memory outputs registry for the duration of a rig build.

class openrig.maya.core.context.NamingStrategy(*args, **kwargs)[source]

Bases: Protocol

Interface every naming convention implementation must satisfy.

Solutions call ctx.namer.build_name(...) — they never import get_manager() directly, keeping them agnostic to which naming convention is active.

build_name(**tokens: object) str[source]

Build a validated name from token key/value pairs.

parse_name(name: str) dict[str, str][source]

Parse a name string into its constituent token values.

class openrig.maya.core.context.BuildContext(namer: NamingStrategy, conventions: RiggingConventions)[source]

Bases: object

Shared state and services for the solution build pipeline.

Carries the naming strategy, rigging conventions, and the in-memory outputs registry. Solutions use this to register their outputs, resolve inputs from other solutions, and query guide positions in the scene.

Parameters:
  • namer – Naming strategy implementation used by all solutions.

  • conventions – Active rigging conventions (axes, rotate order, etc.).

get_output(solution_id: str, port_name: str) str[source]

Return the Maya DAG path registered for an output port.

Parameters:
  • solution_id – Unique identifier of the source solution.

  • port_name – Name of the output port.

Returns:

The registered Maya DAG path string.

Raises:

KeyError – If the solution or port has not been registered yet.

set_output(solution_id: str, port_name: str, value: str) None[source]

Register an output value produced by a built solution.

Called by solutions inside build() for each declared output port.

Parameters:
  • solution_id – Unique identifier of the solution setting the output.

  • port_name – Name of the output port being registered.

  • value – Maya DAG path of the output node.

resolve_input(solution: _SolutionLike, port_name: str) str | None[source]

Resolve a declared input connection to a Maya DAG path.

Looks up the connection declaration for the given port and retrieves the corresponding output from the already-built outputs registry. Returns None if no connection was declared for the port (optional inputs).

Parameters:
  • solution – The solution requesting the input.

  • port_name – Name of the input port to resolve.

Returns:

The Maya DAG path of the connected output, or None if no connection was declared for this port.

Raises:
  • KeyError – If the referenced source solution or port has not been built yet.

  • ValueError – If the stored connection string has an invalid format.

get_guide(solution: _SolutionLike, guide_name: str) tuple[float, float, float] | None[source]

Return the world position of a guide object if it exists in the scene.

Looks for a node named {solution_id}_guides_grp in the Maya scene and navigates to {guides_grp}|{guide_name}. Returns None if not found — the caller falls back to its settings values.

Parameters:
  • solution – The solution whose guides group is searched.

  • guide_name – Short name of the guide node within the guides group.

Returns:

World-space (x, y, z) position tuple, or None if no guide was found.

finalize(rig_root: str) None[source]

Write rig-level and solution-level metadata to Maya nodes.

Called automatically by the build pipeline after all solutions have completed build(). Writes custom string attributes to the rig root and to each solution’s root node so the scene is self-describing.

Rig-level attributes (written to rig_root):
  • openrig_version

  • description_json

  • build_date

Solution-level attributes (written to each solution’s root node):
  • solution_type

  • solution_id

  • settings_json

  • outputs_json

Parameters:

rig_root – Maya DAG path of the rig root node.