Control Factory

Control Factory is a Maya tool for building, authoring, managing, and applying reusable NURBS control shapes for rigging.

The tool provides a dedicated shape library where controls can be organized into custom groups, searched, authored from existing Maya scenes, and applied to new or existing controls. Shapes can be created with customizable scale, rotation, offset, and color, or accessed programmatically through the tool's Python API.

One of the more unique features is the ability to author NURBS control shapes from polygon geometry. Mesh objects and selected mesh components can be converted into reusable NURBS curves, making it possible to use Maya's modeling tools to design control shapes.

The library is also designed to work independently of the UI. Shapes can be loaded and built through Python commands, allowing the same library to be used by autorigging systems and other tools.

Features

  • Shape Library - Store and reuse custom control shapes.

  • Shape Groups - Organize controls into custom categories.

  • Import / Export - Import and export shape groups for easy sharing of shapes between libraries.

  • Search - Quickly find shapes within the library.

  • Shape Authoring - Capture shape data directly from the Maya scene.

  • Mesh to Curve Conversion - Convert mesh objects and selected mesh components into NURBS curves.

  • Paste, Replace, and Combine - Apply shapes to existing transforms or combine multiple shapes into a single transform.

  • Multi-Selection - Select multiple library shapes and apply library operations to them simultaneously.

  • Color Management - Apply Maya indexed colors or RGB colors to controls.

  • Transform Controls - Scale, rotate, and offset shapes when placing them.

  • Pipeline Integration - Build shapes from the library programmatically using Python commands


User Interface

The Control Factory UI provides access to the shape library and scene operations from a single interface.

Shape Groups

The top of the UI contains the shape group selector. Shape groups organize the library into custom categories.

The group options allow shape groups to be added, renamed, deleted, imported, or exported. An All Shapes group is maintained automatically and provides access to every shape in the library.

Search and Shape Grid

The search bar filters the shapes in the current group using fuzzy matching. Matching shapes are displayed in a grid using their saved icons.

Shape buttons support both normal and multi-selection:

  • Single click - Sets the shape as the current shape and clears any existing multi-selection.

  • Shift click - Adds or removes a shape from the current multi-selection.

  • Double click - Builds the selected shape or shapes into the Maya scene.

Shape Library Operations

The buttons below the shape grid manage the contents of the library.

  • Add - Adds the selected shape or shapes to the current shape group.

  • Delete - Removes the selected shape or shapes from the current group. When operating from the All Shapes group, deleting a shape removes it from the library and all other groups.

  • Rename - Renames the current shape in the library. Renaming is limited to single-shape selections.

Scene Operations

The scene operation buttons use methods that operate on the Maya scene based on the scene selected objects.

  • Copy - Captures the selected scene shapes and stores them as a temporary library shape. When multiple objects are selected, the copied shape uses a combination of the selected objects centered at the world origin.

  • Paste - Builds the selected library shape or shapes.

  • Replace - Replaces selected scene shapes with the selected library shape or shapes.

  • Combine - Moves selected NURBS curve shapes onto the first selected transform, combining them into a single object.

Paste, replace, and combine operations are grouped into Maya undo chunks so that each operation can be undone as a single action.

Color

The color button controls the color applied to scene shapes and newly created shapes.

A single click applies the current color to the selected scene shapes, while a double click opens a color selector containing Maya’s index colors.

Shape Placement

The UI provides controls for scale, rotation, and offset. These values are applied when creating, pasting, or replacing shapes.

This allows the same library shape to be reused at different sizes and orientations without modifying the original library data.


Pipeline Integration

Control Factory's library can be used independently of the UI, making it suitable for integration into autorigging systems and other rigging tools.

The underlying functionality is separated into three main classes:

CtrlShapeIO

The CtrlShapeIO class handles communication with the shape library. It is responsible for reading and writing shape data, managing shape groups, resolving shape and icon paths, and maintaining the library structure.

The I/O class is initialized with the path to a shape library, allowing different tools or projects to use different libraries.

Methods

Library

  • set_library(library_path)
    Changes the shape library used by the I/O class and refreshes the library cache.
  • refresh()
    Refreshes the library cache and synchronizes the shape groups with the shapes currently stored in the library.

Shapes

  • load(shape_name, path=None)
    Loads a shape's serialized data. By default, the shape is loaded from the current library, but an optional path can be provided to load a shape from another location.
  • write_shape(shape_name, data)
    Writes serialized shape data to the library under the specified shape name.
  • get_shape_names()
    Returns the names of all shapes in the library, sorted alphabetically without regard to capitalization.
  • rename_shape(old_name, new_name)
    Renames a shape in the library and updates its group membership.
  • delete_shape(shape_name)
    Permanently removes a shape from the library.

Shape Groups

  • create_shape_group(name)
    Creates a new shape group in the library.
  • rename_shape_group(old_name, new_name)
    Renames an existing shape group.
  • delete_shape_group(name)
    Deletes a shape group from the library.
  • add_shape_to_group(group_name, shape_name)
    Adds a shape to a shape group.
  • remove_shape_from_group(group_name, shape_name)
    Removes a shape from a shape group.

Import / Export

  • import_shape(path)
    Imports a shape from a directory into the current library. If a shape with the same name already exists, the imported shape is given an incremented name.
  • import_shape_group(path)
    Imports a directory of shapes to the current shape group. If the shapes with the same name already exist, an incremented name is used.
  • export_shape_group(group_name, path)
    Exports a directory of shapes contained within the shape group using the name of the shape group. If a folder with the same name already exists, an incremented name is used.

CtrlShapeAuthor

The CtrlShapeAuthor class handles extracting shape data from Maya scenes and saving it to a Control Factory library. It takes a CtrlShapeIO instance in its constructor, which it uses to determine where and how shape data should be stored.

The Author class is designed to make it easy to turn existing Maya geometry into reusable Control Factory shapes.

Methods

  • save(objects, shape_name=None)
    Extracts shape data from the provided Maya objects and saves it to the shape library. NURBS curves, mesh faces, and mesh edges can be used to create a reusable control shape.

    If no shape name is provided, the name is generated from the first selected object. If a shape with that name already exists, an incremented name is generated automatically.

import maya.api.OpenMaya as om

selection = om.MGlobal.getActiveSelectionList()

for index in range(selection.length()):
    dag_path, component = selection.getComponent(index)

    objects = om.MSelectionList()
    objects.add(dag_path)

    author.save(objects)

This makes the authoring system particularly useful for building and migrating shape libraries. Shapes can be pulled from existing rigs or another Maya scene and quickly added to a Control Factory library without having to add each shape manually.

CtrlShapeBuilder

The CtrlShapeBuilder class creates and modifies NURBS curves in the Maya scene. It uses a CtrlShapeIO instance to access the shape library.

Methods

  • build(library_shape, name=None, scale=(1, 1, 1), rotate=None, offset=(0, 0, 0), color=None, units=None)
    Creates a curve from a library shape. The optional arguments allow the shape to be customized when it is created.

Build a Library Shape

The only required argument is the name of the library shape:


shape = shape_builder.build(
    library_shape='Circle',
)

The shape can also be customized using the optional arguments:


shape = shape_builder.build(
    library_shape='Circle',
    name='hand_ctrl',
    scale=(2, 2, 2),
    rotate=(0, 0, 45),
    offset=(0, 0, 10),
    color=17,
    units=om.MDistance.kCentimeters,
)

Name specifies the name of the control. If omitted, Maya's default naming behavior is used.

Scale specifies the scale applied to the curve shape, rather than the transform.

Rotate specifies the rotation applied to the curve shape. It can be provided as an (x, y, z) tuple in degrees using kXYZ rotation order, or as an MEulerRotation when a specific rotation order or angle representation is required.


rotation = om.MEulerRotation(
    om.MAngle(45, om.MAngle.kDegrees),
    om.MAngle(0, om.MAngle.kDegrees),
    om.MAngle(90, om.MAngle.kDegrees),
    om.MEulerRotation.kXYZ,
)

shape = shape_builder.build(
    library_shape='Circle',
    rotate=rotation,
)

Offset specifies the translation applied to the curve shape.

Color specifies the curve color and can be provided as either a Maya indexed color or an RGB value.

Units uses a Maya MDistance enum to specify the units used for offset values and the initial creation scale. If omitted, the scene's working units are used.

Shape Editing

  • add_shape(transform, shapes, maintain_offset=True)
    Adds one or more NURBS curve shapes to an existing transform. By default, the shapes maintain their world-space positions when they are added. Set maintain_offset to False to preserve the shapes' local positions instead.
  • replace(transform, shapes_to_add, shapes_to_replace=None, maintain_offset=True)
    Replaces the curve shapes on a transform with the specified shapes. If shapes_to_replace is omitted, all shapes currently on the transform are replaced. The added shapes maintain their world-space positions by default.

Color

  • set_color(transform, color)
    Sets the color of the NURBS curve shapes belonging to a transform. The color can be specified as a Maya indexed color or an RGB value.
  • set_shape_color(shapes, color)
    Sets the color of the specified NURBS curve shape nodes.

Separate Pipeline Libraries

For production use, the library used by pipeline tools can be kept separate from the library used for authoring.

An authoring library can contain experimental and artist-created shapes, while a production library can contain stable shapes used by autorigs and other tools. This prevents changes made while managing the authoring library from unexpectedly affecting production tools.

A valid Control Factory library contains a Shapes directory and a ShapeGroups directory. The Shapes directory contains folders using the shape names and containing the shape data.json and icon.png. The ShapeGroups directory contains json files representing the groups with the list of shapes within the group. When a UI is initialized or its operating library path gets changed, the IO will create the necessary directories if they do not exist. This allows new libraries to easily be set up by instantiating an instance of the IO using a new folder as the library path or changing the library of an existing UI instance to use a new folder as the shape library.