maya ==== .. py:module:: maya .. autoapi-nested-parse:: TikWorks Maya package - Object-oriented wrapper for Maya API. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/maya/constructs/index /autoapi/maya/core/index /autoapi/maya/roles/index /autoapi/maya/types/index /autoapi/maya/utils/index Classes ------- .. autoapisummary:: maya.BlendShape maya.Camera maya.Curve maya.DagNode maya.Joint maya.Light maya.Locator maya.Mesh maya.Node maya.Nurbs maya.ShapeNode maya.Transform Functions --------- .. autoapisummary:: maya.resolve maya.resolve Package Contents ---------------- .. py:class:: BlendShape(long_name, **kwargs) Bases: :py:obj:`maya.core.node.Node` Blendshape node type for Maya. .. py:method:: 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. .. py:method:: 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. .. py:method:: create(**kwargs) :classmethod: Create Blendshape node type for Maya. .. py:method:: 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. .. py:method:: get_weights(geometry=None) Get the global deformer weights. (This corresponds to the BlendShape node entry in the Paint Weights tool). .. py:method:: index_by_name(target_name) Get the index of a target by its name. .. py:method:: 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" .. py:method:: name_by_index(target_index) Get the name of a target by its index. .. py:method:: 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. .. py:method:: set_target_weights(target, weights, geometry=None) Set weights for a specific target shape. Args: target: The index or name of the target. .. py:method:: set_weights(weights, geometry=None) Set the global deformer weights. .. py:property:: base_shapes Return the list of base shapes as list of objects. .. py:property:: influences Return the list of blendshape influences. .. py:property:: next_target :type: int Returns the next free index from a multi index attribute .. py:property:: weight_count Return the number of weight targets. .. py:class:: Camera(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for camera nodes. .. py:method:: create(**kwargs) :classmethod: Create a camera node. Args: **kwargs Additional keyword arguments passed to cmds.camera. Returns: Camera Instance of the created camera node. .. py:method:: delete() Override the deleted method to also delete potential parent aim/up locators. .. py:method:: fit(mode='horizontal') Fit the camera view to the selected objects. Args: mode (str): The fit mode, either "horizontal" or "vertical". .. py:method:: set_controls(mode='camera') Set the Controls for the camera. Args: mode (str): The control mode. Valid values are: "camera", "cameraAndAim", "cameraAimAndUp". .. py:property:: aim Get the aim locator of the camera. .. py:attribute:: control_modes .. py:attribute:: film_fit_modes .. py:property:: lens Get or set the lens (focal length) of the camera. .. py:property:: up Get the up locator of the camera. .. py:class:: Curve(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for NURBS curve nodes. .. py:method:: create(*args, **kwargs) :classmethod: Create a NURBS curve node. .. py:method:: cvs(space='world') Return all control vertex positions. Args: space : str, 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. .. py:method:: scale_points(scale_factor, pivot='object', pivot_point=None) Scale the control points of the curve. Args: scale_factor : float Uniform scale factor to apply to all CVs. pivot : str, optional Pivot mode for scaling. Accepted values are "object", "center" or "custom". Default is "object". pivot_point : tuple of float, optional Custom pivot point (x, y, z) if pivot_mode is "custom". .. py:property:: line_width Get or set the line width of the curve for display purposes. .. py:class:: DagNode(*args, **kwargs) Bases: :py:obj:`maya.core.node.Node` DAG-capable node wrapper with parent/children queries. .. py:method:: create(cmd, name=None, parent=None) :classmethod: Create a node using a maya.cmds command name. Example: 'joint', 'polySphere'. .. py:method:: 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. .. py:method:: get_parent() Return the parent as a wrapped node (or None if no parent). .. py:method:: is_deformable() Check if this node is a deformable geometry type. .. py:method:: rename(new_name) Rename the node. .. py:method:: select() Select this node in the Maya scene. .. py:method:: 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 .. py:method:: 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)). .. py:property:: bounding_box Return the world axis-aligned bounding box of this node. Returns: OpenMaya.MBoundingBox: The bounding box in world space. .. py:property:: children Return children as wrapped nodes. Returns: list: List of child node wrappers. .. py: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 .. py:property:: dag_path Return the MDagPath for this node. Returns: OpenMaya.MDagPath: The DAG path of this node. .. py:attribute:: is_dag :value: True .. py: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. .. py:property:: visibility Get or set the visibility of this transform node. .. py:class:: Joint(*args, **kwargs) Bases: :py:obj:`maya.types.transform.Transform` Wrapper for joint nodes. .. py:method:: create(name=None, parent=None, position=None, orientation=None, scale=None, radius=None) :classmethod: Create and wrap a new joint node. .. py:method:: orient(xyz=(0, 0, 0)) Orient the joint using the provided XYZ values. .. py:property:: radius Get or set the joint radius. .. py:class:: Light(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for light nodes. .. py:method:: create(light_type='pointLight', **kwargs) :classmethod: Create a light node. Args: light_type : str, 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. .. py:class:: Locator(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for locator nodes. .. py:method:: create(**kwargs) :classmethod: Create a locator node. .. py:class:: Mesh(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for mesh nodes. .. py:method:: create(cmd, **kwargs) :classmethod: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: unlock_normals(soften=False) Unlock the normals of the specified geometry. Args: soften (bool, optional): If true, Defaults to False. .. py:method:: vertices(space='world') Return all vertex positions. Args: space : str, 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. .. py:method:: 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. .. py:attribute:: valid_commands .. py:attribute:: valid_primitives .. py:class:: Node(long_name, **kwargs) Base wrapper around a Maya dependency node or DAG node. .. py:method:: 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. .. py:method:: create(cmd, name=None, parent=None) :classmethod: Create a node using a maya.cmds command name. Example: 'joint', 'polySphere'. .. py:method:: delete() Delete the node from the scene. .. py:method:: delete_attr(attr_name) Delete an attribute from the node. Args: attr_name (str): The name of the attribute to delete. .. py:method:: delete_history() Delete the construction history of the node. .. py:method:: duplicate(**kwargs) Duplicate the node in the scene. Returns: Node: A new Node instance representing the duplicated node. .. py:method:: exists() -> bool Return True if the wrapped node still exists in the scene. .. py:method:: 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. .. py:method:: rename(new_name) Rename the node. .. py:attribute:: is_dag :value: False .. py:property:: long_name The full DAG path of the node. .. py:property:: m_obj Return valid MObject, re-resolving from UUID if stale. .. py:property:: name The name of the node. .. py:property:: type The type of the node. .. py:property:: uuid The UUID of the node. .. py:class:: Nurbs(node_name) Bases: :py:obj:`maya.core.shapenode.ShapeNode` Wrapper for NURBS surface nodes. .. py:method:: create(cmd, **kwargs) :classmethod: Create a nurbs surface or primitive (e.g. nurbsPlane). .. py:method:: cvs(space='world') Return all control vertex positions. Args: space : str, 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. .. py:attribute:: valid_commands .. py:attribute:: valid_primitives .. py:class:: ShapeNode(node_name) Bases: :py:obj:`maya.core.dagnode.DagNode` Base for all nodes that have an associated transform + shape relationship. .. py: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. .. py:property:: parent Return the parent as a wrapped node (or None if no parent). Returns: Node or None: The parent node wrapper. .. py:property:: shape Return the shape node itself (for consistency with transform API). Returns: ShapeNode: Returns self. .. py:property:: transform Return the parent transform as a DagNode. Returns: Transform: The parent transform node wrapper. .. py:class:: Transform(*args, **kwargs) Bases: :py:obj:`maya.core.dagnode.DagNode` Wrapper for transform nodes. .. py:method:: 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. .. py:method:: collect_shape_transforms(shape_types=None) Get transforms of shapes under hierarchy of given node. .. py:method:: create(**kwargs) :classmethod: Create a transform node. .. py:method:: 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 "_OFFSET". Defaults to None. Returns: Transform: The created offset transform node. .. py:method:: freeze(translate=True, rotate=True, scale=True) Freeze the transformations on this transform node. .. py:method:: snap_to(target, position=True, rotation=True, scale=False) Snap this transform to another transform's position, rotation, and/or scale. .. py:property:: matrix Return the local matrix of this transform node. Returns: OpenMaya.MMatrix: Local transformation matrix. .. py:property:: parent_matrix Return the local matrix of this transform node's parent. Returns: OpenMaya.MMatrix: Parent's local transformation matrix. .. py:property:: rotate Get or set the rotation of this transform node. .. py:property:: rotate_x Get or set the X rotation of this transform node. .. py:property:: rotate_y Get or set the Y rotation of this transform node. .. py:property:: rotate_z Get or set the Z rotation of this transform node. .. py:property:: scale Get or set the scale of this transform node. .. py:property:: scale_x Get or set the X scale of this transform node. .. py:property:: scale_y Get or set the Y scale of this transform node. .. py:property:: scale_z Get or set the Z scale of this transform node. .. py:property:: shapes :type: list[ShapeNode] Return shape nodes under this transform. .. py:property:: translate Get or set the translation of this transform node. .. py:property:: translate_x Get or set the X translation of this transform node. .. py:property:: translate_y Get or set the Y translation of this transform node. .. py:property:: translate_z Get or set the Z translation of this transform node. .. py:property:: world_matrix Return the world matrix of this transform node. Returns: OpenMaya.MMatrix: World transformation matrix. .. py:property:: world_translation Return the world translation of this transform's rotate pivot. Returns: OpenMaya.MVector: World translation of the rotate pivot. .. py:function:: 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. .. py:function:: 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.