Manually fire the kBeforeProjectLoad event in order to work around a bug in Hiero. The Foundry has logged this bug as: Bug 40413 - Python API - kBeforeProjectLoad event type is not triggered when calling hiero.core.openProject() (only triggered through UI) It exists in all versions of Hiero through (at least) v1.9v1b12.
Once this bug is fixed, a version check will need to be added here in order to prevent accidentally firing this event twice. The following commented-out code is just an example, and will need to be updated when the bug is fixed to catch the correct versions.
Source code in client/ayon_hiero/api/workio.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 | def open_file(filepath):
"""Manually fire the kBeforeProjectLoad event in order to work around a bug in Hiero.
The Foundry has logged this bug as:
Bug 40413 - Python API - kBeforeProjectLoad event type is not triggered
when calling hiero.core.openProject() (only triggered through UI)
It exists in all versions of Hiero through (at least) v1.9v1b12.
Once this bug is fixed, a version check will need to be added here in order to
prevent accidentally firing this event twice. The following commented-out code
is just an example, and will need to be updated when the bug is fixed to catch the
correct versions."""
# if (hiero.core.env['VersionMajor'] < 1 or
# hiero.core.env['VersionMajor'] == 1 and hiero.core.env['VersionMinor'] < 10:
hiero.core.events.sendEvent("kBeforeProjectLoad", None)
project = hiero.core.projects()[-1]
# Close previous project if its different to the current project.
filepath = filepath.replace(os.path.sep, "/")
if project.path().replace(os.path.sep, "/") != filepath:
# open project file
hiero.core.openProject(filepath)
project.close()
return True
|