Hi! I need to create a button that automatically imports a ragdol physics file. The code:
ri.import_physics()
will bring up the Import window. But I need to bypass this and just import a file in one click. What would be the code to do that? Is it possible?
Thanks!
Hi @PepLluis, it sure is. All items accessible via the menu is accessible via Python too. The command you’ve found is the UI command, the one that takes no arguments and brings up a UI, via the ragdoll.interactive
module.
Instead, use the ragdoll.api
module.
from ragdoll import api
api.import_physics(fname)
It takes an opts
argument with start/end frame etc, have a look here for complete details, here’s a summary as of today.
from ragdoll import constants
opts = {
"roots": [],
"matchBy": constants.MatchByHierarchy,
"searchAndReplace": ["", ""],
"namespace": None,
"preserveAttributes": True,
"retarget": True,
"overrideSolver": "",
"createMissingTransforms": False,
}
api.import_physics(fname, opts)
All API functions can be found in api.py
and more low level functions in commands.py