Closed Spyrwon closed 6 months ago
A simple solution may be to force ".rag" onto fname if it does not already have the extension. Since this issue pops up exclusively in Linux we could make this OS dependent. Although this solution assumes that the plugin only exports and will export with the ".rag" file extension. Are there any other file extensions to keep in mind?
Indeed, a miss on our part. .rag
is the only extension today, later there will be a .ragz
for a zip-compressed version. But it's safe to assume that if no extension is given .rag
is a suitable default.
This repo isn't up to date right now so it's tricky to submit PRs for it, I'll add this to my list of things to address and aim to have a release ready by end of this week. For the time being, you can address this locally by editing the export
function in ragdoll/dump.py
.
def export(fname=None, data=None):
"""Export everything Ragdoll-related into `fname`
Arguments:
fname (str, optional): Write to this file
data (dict, optional): Export this dictionary instead
Returns:
data (dict): Exported data as a dictionary
"""
if data is None:
# Pull on solver, both at the start and first frame
# to ensure everything is initialised.
for solver in cmdx.ls(type="rdSolver"):
start_time = int(solver["_startTime"].as_time().value)
solver["startState"].read(time=cmdx.time(start_time))
solver["currentState"].read(time=cmdx.time(start_time + 1))
data = json.loads(cmds.ragdollDump())
if "ui" not in data:
data["ui"] = {}
# Keep filename in the dump
data["ui"]["filename"] = fname or "Memory"
if fname is not None:
if not fname.endswith(".rag"):
fname += ".rag"
with open(fname, "w") as f:
json.dump(data, f, indent=4, sort_keys=True)
cmds.currentTime(cmdx.min_time().value)
return data
Note the if not fname.endswith
line.
Pushed version 2024.05.15, give it a try and feel free to reopen if the problem persists.
Thank you! That was very quick!
Since the .rag extension does not always get added on by default, artist may export physics without adding the extension themselves and then later be confused that their file does not show up when trying to import it, since the plugin exclusively looks for files with the .rag extension. As per https://forums.ragdolldynamics.com/t/rag-extension-issue/1396