Skip to content

Api reference

API Member Reference

The complete Ragdoll API. 🙋‍♂️

from maya import cmds
import ragdoll.api as rd

box = cmds.polyCube()

solver = rd.createSolver()
marker = rd.assignMarker(box[0], solver)

rd.recordPhysics()
Function Description
createSolver Create a new rdSolver node
assignMarkers Assign markers to transforms belonging to solver
assignMarker Convenience function for passing and recieving a single transform
createDistanceConstraint Create a new distance constraint between parent and child
createPinConstraint Create a new pin constraint for child
createFixedConstraint Create a new fixed constraint between parent and child
linkSolver Link solver a with b
unlinkSolver Unlink solver
retargetMarker Retarget marker to transform
untargetMarker Remove parent from child
reparentMarker Make new_parent the new parent of child
unparentMarker Remove parent from child
replaceMesh Replace the 'Mesh' shape type in marker with mesh.
exportPhysics Export everything Ragdoll-related into fname
recordPhysics Transfer simulation from solver to animation land
reinterpretPhysics Recreate Maya scene from exported Ragdoll file
deletePhysics Delete Ragdoll from anything related to nodes
deleteAllPhysics Nuke it from orbit


Argument Signatures

A more in-depth view on each function.

createSolver

Create a new rdSolver node

def createSolver(name, opts):
    """Create a new rdSolver node
               ____
              /    \
          /  |      |
      ---/----\____/
        /       /
    ---/-------/---
      /       /

    The solver is where the magic happens. Markers are connected to it
    and solved within; populating its .outputMatrix attribute with the
    final result.

    Arguments:
        name (str, optional): Override the default name of this solver
        opts (dict, optional): Configure the solver with these options

    Options:
        frameskipMethod (int): Method to use whenever a frame is skipped,
            can be either api.FrameskipPause or api.FrameskipIgnore

    """

assignMarkers

Assign markers to transforms belonging to solver

def assignMarkers(transforms, solver, opts):
    """Assign markers to `transforms` belonging to `solver`

    Each marker transfers the translation and rotation of each transform
    and generates its physical equivalent, ready for recording.

    Options:
        autoLimit (bool): Transfer locked channels into physics limits
        density (enum): Auto-compute mass based on volume and a density,
            such as Flesh or Wood
        materialInChannelBox (bool): Show material attributes in Channel Box
        shapeInChannelBox (bool): Show shape attributes in Channel Box
        limitInChannelBox (bool): Show limit attributes in Channel Box

    """

assignMarker

Convenience function for passing and recieving a single transform

def assignMarker(transform, solver, opts):
    """Convenience function for passing and recieving a single `transform`

    """

createDistanceConstraint

Create a new distance constraint between parent and child

def createDistanceConstraint(parent, child, opts):
    """Create a new distance constraint between `parent` and `child`

    """

createPinConstraint

Create a new pin constraint for child

def createPinConstraint(parent, child, opts):
    """Create a new pin constraint for `child`

    """

createFixedConstraint

Create a new fixed constraint between parent and child

def createFixedConstraint(parent, child, opts):
    """Create a new fixed constraint between `parent` and `child`

    """

linkSolver

Link solver a with b

def linkSolver(a, b, opts):
    """Link solver `a` with `b`

    This will make `a` part of `b`, allowing markers to interact.

    Arguments:
        a (rdSolver): The "child" solver
        b (rdSolver): The "parent" solver

    Returns:
        Nothing

    """

unlinkSolver

Unlink solver

def unlinkSolver(solver, opts):
    """Unlink `solver`

    From any other solver it may be connected to.

    Arguments:
        a (rdSolver): The solver to unlink from any other solver

    Returns:
        Nothing

    """

retargetMarker

Retarget marker to transform

def retargetMarker(marker, transform, opts):
    """Retarget `marker` to `transform`

    When recording, write simulation from `marker` onto `transform`,
    regardless of where it is assigned.

    """

untargetMarker

Remove parent from child

def untargetMarker(marker, opts):
    """Remove parent from `child`

    Meaning `child` will be a free marker, without a parent.

    """

reparentMarker

Make new_parent the new parent of child

def reparentMarker(child, parent, opts):
    """Make `new_parent` the new parent of `child`

    Arguments:
        child (rdMarker): The marker whose about to have its parent changed
        new_parent (rdMarker): The new parent of `child`

    """

unparentMarker

Remove parent from child

def unparentMarker(child, opts):
    """Remove parent from `child`

    Meaning `child` will be a free marker, without a parent.

    """

replaceMesh

Replace the 'Mesh' shape type in marker with mesh.

def replaceMesh(marker, mesh, opts):
    """Replace the 'Mesh' shape type in `marker` with `mesh`.

    Arguments:
        marker (cmdx.Node): Rigid whose mesh to replace
        mesh (cmdx.Node): Mesh to replace with
        clean (bool, optional): Remove other inputs, such as curve
            or surface node. Multiple inputs are supported, so this
            is optional. Defaults to True.

    Returns:
        Nothing

    """

exportPhysics

Export everything Ragdoll-related into fname

def exportPhysics(fname, opts):
    """Export everything Ragdoll-related into `fname`

    Arguments:
        fname (str, optional): Write to this file
        data (dict, optional): Export this dictionary instead

    Returns:
        data (dict): Exported data as a dictionary

    """

recordPhysics

Transfer simulation from solver to animation land

def recordPhysics(solver, opts):
    """Transfer simulation from `solver` to animation land

    Options:
        start_time (int, optional): Record from this time
        end_time (int, optional): Record to this time
        include (list, optional): Record these transforms only
        exclude (list, optional): Do not record these transforms
        kinematic (bool, optional): Record kinematic frames too
        maintain_offset (bool, optional): Maintain whatever offset is
            between the source and destination transforms, default
            value is True

    """

reinterpretPhysics

Recreate Maya scene from exported Ragdoll file

def reinterpretPhysics(fname, opts):
    """Recreate Maya scene from exported Ragdoll file

    User-interface attributes like `density` and display settings
    are restored from a file otherwise mostly contains the raw
    simulation data.

    """

deletePhysics

Delete Ragdoll from anything related to nodes

def deletePhysics(nodes):
    """Delete Ragdoll from anything related to `nodes`

    This will delete anything related to Ragdoll from your scenes, including
    any attributes added (polluted) onto your animation controls.

    Arguments:
        nodes (list): Delete physics from these nodes
        dry_run (bool, optional): Do not actually delete anything,
            but still run through the process and throw exceptions
            if any, and still return the results of what *would*
            have been deleted if it wasn't dry.

    """

deleteAllPhysics

Nuke it from orbit

def deleteAllPhysics():
    """Nuke it from orbit

    Return to simpler days, days before physics, with this one command.

    """


Constants

Some functions take constants for arguments.

from ragdoll import api
api.assign_marker(a, b, opts={"density": api.DensityFlesh})
Constant Value
FrameskipPause 0
FrameskipIgnore 1
DisplayDefault 0
DisplayWire 1
DisplayConstant 2
DisplayShaded 3
DisplayMass 4
DisplayFriction 5
DisplayRestitution 6
DisplayVelocity 7
DisplayContacts 8
InputInherit 0
InputOff 1
InputKinematic 2
InputGuide 3
PGSSolverType 0
TGSSolverType 1
BoxShape 0
SphereShape 1
CapsuleShape 2
MeshShape 4
ConvexHullShape 4
DensityOff 0
DensityCotton 1
DensityWood 2
DensityFlesh 3
DensityUranium 4
DensityBlackHole 5
DensityCustom 6
StartTimeRangeStart 0
StartTimeAnimationStart 1
StartTimeCustom 2

Last update: 2022-01-16