Physics Field Toggling Tool

Hi all,

Here’s a small simple tool for you to:

  • Quick toggling physic force fields!

Just copy the following script into your Maya script editor tab (python) and run it. And you should see a small window pops up with all your fields listed as checkbox!

# RagdollDynamics: Field Toggler

from maya import cmds
from ragdoll.vendor import cmdx
from functools import partial

def get_fields():
    for solver in"rdSolver"):
        a = str(solver) + ".owner"
        for fd in cmds.listConnections(a, s=1, t="field"):
            yield solver, cmdx.encode(fd)

def ui_enable_field(field, solver, *args):
    with cmdx.DagModifier() as mod:
        index = solver["inputFields"].next_available_index()
        mod.connect(field["message"], solver["inputFields"][index])

def ui_disable_field(i, field, *args):
    conn = iter(cmds.listConnections(i, c=1))
    for p, f in zip(conn, conn):
        if f == field:
            cmds.disconnectAttr(f + ".message", p)

def make_gui():
    name = "rdSolverFieldsGUI"
    if cmds.window(name, q=1, ex=1):
    window = cmds.window(name)
    for s, f in get_fields():
        _i = s.shortestPath() + ".inputFields"
        v = in (cmds.listConnections(_i) or [])
        onc = partial(ui_enable_field, f, s)
        ofc = partial(ui_disable_field, _i,
        cmds.checkBox(, v=v, onc=onc, ofc=ofc)


Quick walkthrough :slight_smile:

Hope you find this useful :heart: