Developing Scripts#

To develop and test rigging code with Paya:

  1. Swap out import pymel.core for import paya.runtime wherever needed.

  2. Apply patching only once, at the level of execution.

In the case of scripted rig builds, calls might look something like this:

# Order of imports doesn't matter
from mylib.buildBiped import build
import paya.runtime

with paya.runtime:
    build()

In studio contexts, care should be taken to keep pipeline calls away from patch blocks:

from studiolib import initAsset, publishAsset
from mylib.buildBiped import build
import paya.runtime

initAsset()

with paya.runtime:
    build()

publishAsset()
from studiolib import initAsset, publishAsset
from mylib.buildBiped import build
import paya.runtime

with paya.runtime:
    initAsset() # should not be called with PyMEL patched
    build()
    publishAsset() # should not be called with PyMEL patched

Patching can also be applied using paya.runtime as a decorator rather than a context manager. This can be more convenient when the ‘level of execution’ is the function itself, as in the case of interactive tools:

import paya.runtime as r

@r
def createOffsetGroups():
    transforms = r.ls(sl=True, type='transform')

    for transform in transforms:
        transform.createOffsetGroups()