Python command to import a rag file

Hello. I’m trying to make a python command to import a rag file.
After this command, a window opens where you can select a rag file. But I want the file to be selected automatically at the specified path
(D:\my_custom_physics.rag)

from ragdoll import interactive as ri
ri.import_physics()

Please could you suggest how to import my_custom_physics.rag so that the window doesn’t open.

Hi @eumelnikov, thanks for re-posting here from the Discord chat, and welcome to the forums! :partying_face:

To import via Python, you can use the api.reinterpret_physics() command.

from ragdoll import api
fname = r"D:\my_custom_physics.rag"
api.reinterpret_physics(fname)

You can pass in optional parameters the are usually accessed via the Import dialog via the opts argument.

api.reinterpret_physics(fname, opts={
    "roots": [],
    "matchBy": constants.MatchByHierarchy,
    "searchAndReplace": ["", ""],
    "namespace": None,
    "preserveAttributes": True,
    "retarget": True,

    "overrideSolver": "",
    "createMissingTransforms": False,
})

Hope it helps!

1 Like

Hi, marcus
Of course you helped. Thanks a lot!