Issue sending simulation in batch mode

Hey There, I’m experiencing a weird issue sending in batch a couple of simulations. Basically I’m using the following command for baking the simulations onto rig controls:

from ragdoll import api
api.record_physics(solver=ragdoll_solver, opts={'startTime': frame_start, 'endTime': frame_end, 'includeKinematic': True})

but seems like at the end of the simulations the log gives me a message where is written:

ragdoll._bake() - Nothing was baked

That is a little strange because I have all my markers set to record both Translation and Rotation.


Hi @Fabio_Fiordalice, welcome to the forums! :partying_face:

This can happen for a few reasons.

  1. Every Marker has been Untargeted
  2. Every Marker is set to Animated (previously known as “Kinematic”)

Try calling Ragdoll → Utilities → Extract Simulation to see if anything is produced. You should find a joint hierarchy containing your simulation. Next, you can go the options for Extract Simulation and tick Attach Controls to mimic how Record Simulation works, just before it bakes things to keyframes.

You should find your controls now constrained to the extracted simulation. From here, you can manually call Maya’s Edit → Keys → Bake Simulation and you will have effectively done a manual Record Simulation.

As you progress through these steps, I expect you’ll discover the cause of the issue. If not, let us know here and we’ll continue investigating!

Hey Marcus,
thank you for the heads up about the extract markers tool.

Anyway I would like giving you a background of the situation: basically we have some shots where there are from 40 to 200 rigs (it depends from the shot) and all those are driven by the ragdoll system; so after a quick test by our artists, we would like to send that scene in farm in order (as I already said in the previous post) to speed up the simulation and baking processes.
We’ve already developed a simple batch script where we use the ragdoll api/interactive/recording modules to reproducing what the Record Simulation does:


but seems like every time we run a different type of record in batch, something just go wrong, and if we run the same code in maya (interactive mode) everything it’s just fine and we are able to run a record and bake the recorded simulation on rigs controls.

For example what you said about the Extract Marker it was working for us since we were trying to bake controls with the maya command cmds.bakeResults… on that time the process seems like frozen and it won’t continue (again this issue appears only in batch mode).

I’ve also noticed that sometimes maya session just crash when we try to api.deleteAllPhysics after ragdoll system has been simulated and transferred to the rigs (I’m not sure if this will help you).
And related to this if we commented out the delete function, the script seems working fine without any crash but after we open up the saved scene with the simulated ragdoll physics those ones just go crazy and explode during the playback.

Here the related script we would like to use:

# Standard modules
import sys
import os
import traceback

# External modules
import maya.standalone
from maya import cmds
from sys import argv


def main(maya_scene_filepath, ragdoll_solver, frame_start, frame_end, final_scene_path):
    """ Main function to export .abc animation cache.

        RuntimeError: if export .abc fails
        from ragdoll import api, interactive, recording
        from ragdoll.vendor import cmdx

        print('# ---> Opening maya scene - {}'.format(maya_scene_filepath))
        cmds.file(maya_scene_filepath, open=True, force=True)

        cmds.playbackOptions(edit=True, maxTime=frame_start, minTime=frame_end)

        # api.recordPhysics(solver=ragdoll_solver, opts={'start_time': frame_start, 'end_time': frame_end})
        # api.recordPhysics(solver=ragdoll_solver, opts={'startTime': frame_start, 'endTime': frame_end, 'includeKinematic': True})
        # interactive.extract_markers(ragdoll_solver, {'markersExtractAndAttach':True})
        # interactive.record_markers(ragdoll_solver)

        print('# ---> Setting current time to {}...'.format(frame_start))
        cmds.currentTime(frame_start, edit=True)

        print('# ---> Selecting the Ragdool Solver node...')'|ragdoll_grp|rSolver|rSolverShape')
        api.recordPhysics(solver='|ragdoll_grp|rSolver|rSolverShape', opts={'start_time': frame_start, 'end_time': frame_end})


        print('# ---> Deleting all Ragdoll Physics nodes...')
        # api.deleteAllPhysics()

        print('# ---> Saving the scene: {} ...'.format(maya_scene_filepath))
        # file_manager.save_file(maya_scene_filepath)
        cmds.file(save=True, type='mayaAscii')

        print('# ---> Done...')
        return True

        raise RuntimeError

if __name__ == "__main__":
    maya_scene_filepath = sys.argv[1]
    ragdoll_solver = sys.argv[2]
    frame_start = int(sys.argv[3])
    frame_end = int(sys.argv[4])
    final_scene_path = sys.argv[5]

    main(maya_scene_filepath, ragdoll_solver, frame_start, frame_end, final_scene_path)

One more question… what do you mean with Marker Untargeted? Should we pass all the markers DagObject to the extract_markers function? Because as far as I can see from the ragdoll’s python scripts, it needs just the solver and then everything will be extracted.

Thanks in advance for you help.

One little feedback more…
I was trying to manually implement what you were saying with the extract markers tool and everything seems ok during the maya session but once I open the output scene each ragdoll just explode (as I mentioned in the previous answer) and the rig controls are baked (thanks to the maya bakeResults) but without any changes in the transformations, like all the animation keys set to 0 for each frame.

Before the extract markers + bake:

After the extract markers + bake:

Hey @Fabio_Fiordalice, thanks for the update. I’m just going offline for the night, but will take a closer look in the morning. If there is anything you can send me, either a minimal scene to reproduce the issue or some steps I can follow, that would help narrow things down. Overall everything sounds OK with your approach.

Thanks for the reply Marcus,
can you tell me how can I send you some things as material that you can use for reproducing the problem? Maybe a wetransfer link?

And because those materials are confidential, do you have a private/support mail where we can send them?

Thanks a lot

Sorry for not getting on this sooner, been a busy day. Yes, you can send anything private to Expect to have this looked at within the next 24 hours.

Cool thanks for that… I’ll prepare for you a simple scene tomorrow morning with a few rigs to work with.

Thanks a lot.

Having a look at this now. Can you confirm:

  1. Which version of Maya? Including patch version, e.g. 2022.2
  2. Which version of Ragdoll?
  3. Which OS is this? Looks like Linux, but do confirm

Just to clarify, the Record Simulation does exactly this; calls Extract Simulation with “Attach Controls” ticked, and then runs cmds.bakeResults. Doing this manually should have an identical effect, except Record Simulation also cleans up after itself by removing the extracted skeleton and constraints.

Did you manage to narrow down why no controls were recorded via the Record Simulation command? I was hoping it would shed some light on which controls got attached and which was not. Sometimes controls have special locked or connected channels that can prevent the Maya constraints from taking effect.

Hm, there is a known issue with Maya 2022.0 (the first release, no patches) whereby Ragdoll was unable to delete its nodes. Autodesk addressed this shortly after release with 2022.1. Can you confirm which version of Maya you are on?

Here’s another thing you can use to debug this issue. Once Extract Simulation has been called, Ragdoll is no longer in the loop. The command outputs a completely native joint hierarchy with native keyframes. From here, the process runs entirely inside of native Maya. So any freezes or crashes should be reproducible outside of Ragdoll. For example, if you were to manually constrain your controls and call cmds.bakeResults, it should also freeze. We won’t be able to help you with this kind of issue, it would be studio/rig related.

This is odd, since deleting physics after having recorded should not have any effect on what was recorded, can you clarify what you mean here? I’m also seeing the following post with the exploded controls.

It’s especially tricky to narrow this issue down because (1) I have nothing to test and (2) you appear to be on Linux and running in batch, which is exactly how our internal tests are run for each release. You are in the ideal circumstances for doing what you are attempting to do. :sweat_smile:

I see you just sent some material via email, taking a look at this now and will return shortly!

I’ve had a look, and have a few observations.

  1. It appears you are on Maya 2022.0, which means you are struck by the bug which prevents you from deleting markers. Simply not deleting them will circumvent this, although this version of Maya likely has a number of other issues so I would suggest moving to 2022.1 or above.
  2. The version of Ragdoll is 2022.11.20, we cannot support versions other than the currently latest version

I wasn’t able to open the file with 40 referenced characters, but I was able to open the original file and noticed that the default Import Physics option of Match By: Name struggles to find matching names in this rig, similar to this issue:

If you use Import Physics, try the alternative Match By: Hierarchy instead, that seemed to do the trick.

Otherwise you may end up with errors like these when recording, because it tries to retarget onto the wrong controls.

UnboundLocalError: local variable 'connections' referenced before assignment

Apart from that, I was unable to reproduce the issue. Here’s a reproducible of what works on this end, can you confirm? I assigned a few markers and made a new .rag file to import into the animation scene, which is how I believe you have also done since there was no physics in the rig file. Let me know otherwise. (48.5 KB)

import os
from maya import standalone

from maya import cmds
cmds.file(new=True, force=True)

rigfname = "/path/to/"
cmds.file(rigfname, reference=True, namespace="_")

from ragdoll import api
ragfname = "/path/to/bear.rag"
api.reinterpretPhysics(ragfname, opts={"matchBy": api.MatchByHierarchy})

# To create some interesting motion
con = api.create_pin_constraint("rMarker_c_head_01_bind_jnt")
cmds.setAttr(con + ".linearStiffness", 0.05)  # Translate Stiffnessv

solver ="rdSolver")[0]
api.recordPhysics(solver, opts={"startTime": 0, "endTime": 20})


outfname = os.path.dirname(rigfname)
outfname = os.path.join(outfname, "")
cmds.file(save=True, type="mayaAscii")

print("Successfully saved simulated file @ %s" % outfname)