maya¶
TikWorks Maya package - Object-oriented wrapper for Maya API.
Submodules¶
Classes¶
Blendshape node type for Maya. |
|
Wrapper for camera nodes. |
|
Wrapper for NURBS curve nodes. |
|
DAG-capable node wrapper with parent/children queries. |
|
Wrapper for joint nodes. |
|
Wrapper for light nodes. |
|
Wrapper for locator nodes. |
|
Wrapper for mesh nodes. |
|
Base wrapper around a Maya dependency node or DAG node. |
|
Wrapper for NURBS surface nodes. |
|
Base for all nodes that have an associated transform + shape relationship. |
|
Wrapper for transform nodes. |
Functions¶
Package Contents¶
- class BlendShape(long_name, **kwargs)¶
Bases:
maya.core.node.NodeBlendshape node type for Maya.
- add_inbetween(target, target_geometry, weight=0.5, **kwargs)¶
Add an in-between target shape to an existing target.
- Args:
target: The index or name of the target to add the in-between to. target_geometry: The geometry to add as the in-between target. weight: The weight value at which the in-between is active.
- add_target(target_geometry, name=None, weight=1.0, **kwargs)¶
Add a new target shape to the blendshape.
- Args:
geometry: The geometry to add as a target. name: Optional name for the target. weight: Initial weight value for the target.
- Returns:
int: The index of the newly added target.
- classmethod create(**kwargs)¶
Create Blendshape node type for Maya.
- get_target_weights(target, geometry=None)¶
Get weights for a specific target shape (e.g. ‘pCube2’). Args:
target: The index or name of the target.
- get_weights(geometry=None)¶
Get the global deformer weights. (This corresponds to the BlendShape node entry in the Paint Weights tool).
- index_by_name(target_name)¶
Get the index of a target by its name.
- load_weights(file_path, method='index', **kwargs)¶
Import blendshape weights from a file.
- Args:
file_path (str or Path Object): The file path to import weights from. method (str): The method to use for importing weights.
Valid values are: “index”, “nearest”, “barycentric”, “bilinear” and “over”
- name_by_index(target_index)¶
Get the name of a target by its index.
- save_weights(file_path, **kwargs)¶
Export blendshape weights to a file.
- Args:
file_path (str or Path Object): The file path to export weights to.
- set_target_weights(target, weights, geometry=None)¶
Set weights for a specific target shape. Args:
target: The index or name of the target.
- set_weights(weights, geometry=None)¶
Set the global deformer weights.
- property base_shapes¶
Return the list of base shapes as list of objects.
- property influences¶
Return the list of blendshape influences.
- property next_target: int¶
Returns the next free index from a multi index attribute
- property weight_count¶
Return the number of weight targets.
- class Camera(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for camera nodes.
- classmethod create(**kwargs)¶
Create a camera node.
- Args:
- **kwargs
Additional keyword arguments passed to cmds.camera.
- Returns:
- Camera
Instance of the created camera node.
- delete()¶
Override the deleted method to also delete potential parent aim/up locators.
- fit(mode='horizontal')¶
Fit the camera view to the selected objects.
- Args:
mode (str): The fit mode, either “horizontal” or “vertical”.
- set_controls(mode='camera')¶
Set the Controls for the camera.
- Args:
- mode (str): The control mode. Valid values are:
“camera”, “cameraAndAim”, “cameraAimAndUp”.
- property aim¶
Get the aim locator of the camera.
- control_modes¶
- film_fit_modes¶
- property lens¶
Get or set the lens (focal length) of the camera.
- property up¶
Get the up locator of the camera.
- class Curve(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for NURBS curve nodes.
- classmethod create(*args, **kwargs)¶
Create a NURBS curve node.
- cvs(space='world')¶
Return all control vertex positions.
- Args:
- spacestr, optional
Coordinate space to return the CVs in. Accepted values: “world”, “object”, “transform”. Default is “world”.
- Returns:
- OpenMaya.MPointArray
Array of CV positions in the requested space.
- scale_points(scale_factor, pivot='object', pivot_point=None)¶
Scale the control points of the curve.
- Args:
- scale_factorfloat
Uniform scale factor to apply to all CVs.
- pivotstr, optional
Pivot mode for scaling. Accepted values are “object”, “center” or “custom”. Default is “object”.
- pivot_pointtuple of float, optional
Custom pivot point (x, y, z) if pivot_mode is “custom”.
- property line_width¶
Get or set the line width of the curve for display purposes.
- class DagNode(*args, **kwargs)¶
Bases:
maya.core.node.NodeDAG-capable node wrapper with parent/children queries.
- classmethod create(cmd, name=None, parent=None)¶
Create a node using a maya.cmds command name.
Example: ‘joint’, ‘polySphere’.
- get_color(as_color=False)¶
Get the display color of the controller shapes.
- Args:
- as_color (bool, optional): If True, and if its RGB colors,
return a tik.core.color.Color obj.
- get_parent()¶
Return the parent as a wrapped node (or None if no parent).
- is_deformable()¶
Check if this node is a deformable geometry type.
- rename(new_name)¶
Rename the node.
- select()¶
Select this node in the Maya scene.
- set_color(color)¶
Set the display color of the controller shapes.
- Args:
- color (int | tuple | list | Color):
int: Maya index color (0-31)
tuple/list: RGB values (0.0 - 1.0)
tik.core.Color: Color object
None: Disable color override
- set_parent(new_parent: Any, relative: bool = False) None¶
Set a new parent for this node.
- Args:
new_parent: New parent node (str, Node wrapper, or None for world). relative: If True, keep local transforms (no world-space compensation).
If False (default), preserve world-space placement by compensating transforms after parenting (similar to cmds.parent(relative=False)).
- property bounding_box¶
Return the world axis-aligned bounding box of this node.
- Returns:
OpenMaya.MBoundingBox: The bounding box in world space.
- property children¶
Return children as wrapped nodes.
- Returns:
list: List of child node wrappers.
- property color¶
Get or set the display color of the node.
- Can be set to:
int: Maya index color (0-31)
tuple/list: RGB values (0.0-1.0)
Color: tik.core.Color object
None: Disable color override
- property dag_path¶
Return the MDagPath for this node.
- Returns:
OpenMaya.MDagPath: The DAG path of this node.
- is_dag = True¶
- property parent¶
Return the parent as a wrapped node (or None if no parent).
- Returns:
Node wrapper or None: The parent node, or None if this is a world-level node.
- property visibility¶
Get or set the visibility of this transform node.
- class Joint(*args, **kwargs)¶
Bases:
maya.types.transform.TransformWrapper for joint nodes.
- classmethod create(name=None, parent=None, position=None, orientation=None, scale=None, radius=None)¶
Create and wrap a new joint node.
- orient(xyz=(0, 0, 0))¶
Orient the joint using the provided XYZ values.
- property radius¶
Get or set the joint radius.
- class Light(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for light nodes.
- classmethod create(light_type='pointLight', **kwargs)¶
Create a light node.
- Args:
- light_typestr, optional
Type of light to create. Default is “pointLight”. Accepted values include “pointLight”, “directionalLight”, “spotLight”, “areaLight”, “ambientLight”, etc.
- **kwargs
Additional keyword arguments passed to cmds.createNode.
- Returns:
- Light
Instance of the created light node.
- class Locator(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for locator nodes.
- classmethod create(**kwargs)¶
Create a locator node.
- class Mesh(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for mesh nodes.
- classmethod create(cmd, **kwargs)¶
Create a mesh or polygon primitive.
- Args:
cmd (str): The Maya command to create the mesh (e.g. ‘polySphere’). **kwargs: Additional keyword arguments to pass to the command.
- get_vertex_colors(indices=None)¶
Get vertex colors.
- Args:
indices (list[int], optional): List of vertex indices to retrieve colors for.
- Returns:
OpenMaya.MColorArray or None: Vertex colors if they exist, else None.
- set_vertex_colors(color, indices=None)¶
Set vertex color for vertices.
- Args:
- color (tuple or color.Color): RGB color values as a tuple of three floats (0.0 to 1.0)
or color.Color object.
indices (list[int], optional): List of vertex indices to set color for.
- unlock_normals(soften=False)¶
Unlock the normals of the specified geometry.
- Args:
soften (bool, optional): If true, Defaults to False.
- vertices(space='world')¶
Return all vertex positions.
- Args:
- spacestr, optional
Coordinate space to return the vertices in. Accepted values: “world”, “object”, “transform”. Default is “world”.
- Returns:
- OpenMaya.MPointArray
Array of vertex positions in the requested space.
- vertices_in_radius(point_coordinates, radius=0.2)¶
Return vertex indices within a radius from a point in space.
- Args:
point (OpenMaya.MPoint): The center point to measure from. radius (float, optional): The radius distance. Defaults to 0.2.
- Returns:
list: List of vertex indices within the radius.
- valid_commands¶
- valid_primitives¶
- class Node(long_name, **kwargs)¶
Base wrapper around a Maya dependency node or DAG node.
- add_attr(attr_name, **kwargs)¶
Add a new attribute to the node.
- Args:
attr_name (str): The name of the attribute to add. **kwargs: Additional keyword arguments to pass to cmds.addAttr.
- Returns:
Plug: A Plug instance representing the newly added attribute.
- classmethod create(cmd, name=None, parent=None)¶
Create a node using a maya.cmds command name.
Example: ‘joint’, ‘polySphere’.
- delete()¶
Delete the node from the scene.
- delete_attr(attr_name)¶
Delete an attribute from the node.
- Args:
attr_name (str): The name of the attribute to delete.
- delete_history()¶
Delete the construction history of the node.
- duplicate(**kwargs)¶
Duplicate the node in the scene.
- Returns:
Node: A new Node instance representing the duplicated node.
- exists() bool¶
Return True if the wrapped node still exists in the scene.
- has_attr(attr_name)¶
Check if the node has the given attribute.
- Args:
attr_name (str): The name of the attribute to check.
- Returns:
bool: True if the attribute exists, False otherwise.
- rename(new_name)¶
Rename the node.
- is_dag = False¶
- property long_name¶
The full DAG path of the node.
- property m_obj¶
Return valid MObject, re-resolving from UUID if stale.
- property name¶
The name of the node.
- property type¶
The type of the node.
- property uuid¶
The UUID of the node.
- class Nurbs(node_name)¶
Bases:
maya.core.shapenode.ShapeNodeWrapper for NURBS surface nodes.
- classmethod create(cmd, **kwargs)¶
Create a nurbs surface or primitive (e.g. nurbsPlane).
- cvs(space='world')¶
Return all control vertex positions.
- Args:
- spacestr, optional
Coordinate space to return the CVs in. Accepted values: “world”, “object”, “transform”. Default is “world”.
- Returns:
- OpenMaya.MPointArray
Array of CV positions in the requested space.
- valid_commands¶
- valid_primitives¶
- class ShapeNode(node_name)¶
Bases:
maya.core.dagnode.DagNodeBase for all nodes that have an associated transform + shape relationship.
- property long_name¶
Return the full DAG path, respecting the specific instance path if possible.
- Returns:
str: The full DAG path to this shape node.
- property parent¶
Return the parent as a wrapped node (or None if no parent).
- Returns:
Node or None: The parent node wrapper.
- property shape¶
Return the shape node itself (for consistency with transform API).
- Returns:
ShapeNode: Returns self.
- property transform¶
Return the parent transform as a DagNode.
- Returns:
Transform: The parent transform node wrapper.
- class Transform(*args, **kwargs)¶
Bases:
maya.core.dagnode.DagNodeWrapper for transform nodes.
- collect_hierarchy(node_types=None, include_self=False, max_depth=-1)¶
Collect nodes in the hierarchy under this transform.
- Args:
- node_types (list[str], optional): List of node types to include.
If None, includes all types. Defaults to None.
- include_self (bool, optional): Whether to include this node.
Defaults to False.
- max_depth (int, optional): Maximum depth to traverse.
-1 for unlimited. Defaults to -1.
- Returns:
list[DagNode]: List of collected nodes.
- collect_shape_transforms(shape_types=None)¶
Get transforms of shapes under hierarchy of given node.
- classmethod create(**kwargs)¶
Create a transform node.
- create_offset_group(name: str = None) Transform¶
Create an offset transform above this transform in the hierarchy.
- Args:
- name (str, optional): Name for the offset transform.
If None, defaults to “<this_node_name>_OFFSET”. Defaults to None.
- Returns:
Transform: The created offset transform node.
- freeze(translate=True, rotate=True, scale=True)¶
Freeze the transformations on this transform node.
- snap_to(target, position=True, rotation=True, scale=False)¶
Snap this transform to another transform’s position, rotation, and/or scale.
- property matrix¶
Return the local matrix of this transform node.
- Returns:
OpenMaya.MMatrix: Local transformation matrix.
- property parent_matrix¶
Return the local matrix of this transform node’s parent.
- Returns:
OpenMaya.MMatrix: Parent’s local transformation matrix.
- property rotate¶
Get or set the rotation of this transform node.
- property rotate_x¶
Get or set the X rotation of this transform node.
- property rotate_y¶
Get or set the Y rotation of this transform node.
- property rotate_z¶
Get or set the Z rotation of this transform node.
- property scale¶
Get or set the scale of this transform node.
- property scale_x¶
Get or set the X scale of this transform node.
- property scale_y¶
Get or set the Y scale of this transform node.
- property scale_z¶
Get or set the Z scale of this transform node.
- property translate¶
Get or set the translation of this transform node.
- property translate_x¶
Get or set the X translation of this transform node.
- property translate_y¶
Get or set the Y translation of this transform node.
- property translate_z¶
Get or set the Z translation of this transform node.
- property world_matrix¶
Return the world matrix of this transform node.
- Returns:
OpenMaya.MMatrix: World transformation matrix.
- property world_translation¶
Return the world translation of this transform’s rotate pivot.
- Returns:
OpenMaya.MVector: World translation of the rotate pivot.
- resolve(name: str, class_name=None) Any¶
Return an instance of the correct Node subclass based on Maya node type.
- Args:
name: Name of the Maya node, or an existing wrapper instance. class_name: Optional specific class name to use from registry.
- Returns:
A wrapper instance for the node.
- Raises:
LookupError: If class_name is specified but not registered.
- resolve(name: str, class_name=None) Any¶
Return an instance of the correct Node subclass based on Maya node type.
- Args:
name: Name of the Maya node, or an existing wrapper instance. class_name: Optional specific class name to use from registry.
- Returns:
A wrapper instance for the node.
- Raises:
LookupError: If class_name is specified but not registered.