mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
Merge pull request #135 from BigRoy/master
Fix FUS-48 loader offsett not correct and improve filepath check in script
This commit is contained in:
commit
ae55e59f2c
2 changed files with 26 additions and 12 deletions
|
|
@ -82,9 +82,13 @@ def loader_shift(loader, frame, relative=True):
|
|||
comp = loader.Comp()
|
||||
time = comp.TIME_UNDEFINED
|
||||
|
||||
if not relative:
|
||||
start = loader["GlobalIn"][time]
|
||||
frame -= start
|
||||
old_in = loader["GlobalIn"][time]
|
||||
old_out = loader["GlobalOut"][time]
|
||||
|
||||
if relative:
|
||||
shift = frame
|
||||
else:
|
||||
shift = frame - old_in
|
||||
|
||||
# Shifting global in will try to automatically compensate for the change
|
||||
# in the "ClipTimeStart" and "HoldFirstFrame" inputs, so we preserve those
|
||||
|
|
@ -93,9 +97,17 @@ def loader_shift(loader, frame, relative=True):
|
|||
"ClipTimeEnd",
|
||||
"HoldFirstFrame",
|
||||
"HoldLastFrame"]):
|
||||
loader["GlobalIn"][time] = loader["GlobalIn"][time] + frame
|
||||
|
||||
return int(frame)
|
||||
# GlobalIn cannot be set past GlobalOut or vice versa
|
||||
# so we must apply them in the order of the shift.
|
||||
if shift > 0:
|
||||
loader["GlobalOut"][time] = old_out + shift
|
||||
loader["GlobalIn"][time] = old_in + shift
|
||||
else:
|
||||
loader["GlobalIn"][time] = old_in + shift
|
||||
loader["GlobalOut"][time] = old_out + shift
|
||||
|
||||
return int(shift)
|
||||
|
||||
|
||||
class FusionLoadSequence(api.Loader):
|
||||
|
|
|
|||
|
|
@ -157,19 +157,22 @@ def switch(asset_name, filepath=None, new=True):
|
|||
|
||||
"""
|
||||
|
||||
# Ensure filename is absolute
|
||||
if not os.path.abspath(filepath):
|
||||
filepath = os.path.abspath(filepath)
|
||||
# If filepath provided, ensure it is valid absolute path
|
||||
if filepath is not None:
|
||||
if not os.path.isabs(filepath):
|
||||
filepath = os.path.abspath(filepath)
|
||||
|
||||
# Get current project
|
||||
self._project = io.find_one({"type": "project",
|
||||
"name": api.Session["AVALON_PROJECT"]})
|
||||
assert os.path.exists(filepath), "%s must exist " % filepath
|
||||
|
||||
# Assert asset name exists
|
||||
# It is better to do this here then to wait till switch_shot does it
|
||||
asset = io.find_one({"type": "asset", "name": asset_name})
|
||||
assert asset, "Could not find '%s' in the database" % asset_name
|
||||
|
||||
# Get current project
|
||||
self._project = io.find_one({"type": "project",
|
||||
"name": api.Session["AVALON_PROJECT"]})
|
||||
|
||||
# Go to comp
|
||||
if not filepath:
|
||||
current_comp = avalon.fusion.get_current_comp()
|
||||
|
|
@ -189,7 +192,6 @@ def switch(asset_name, filepath=None, new=True):
|
|||
representation = colorbleed.switch_item(container,
|
||||
asset_name=asset_name)
|
||||
representations.append(representation)
|
||||
current_comp.Print(str(representation["_id"]) + "\n")
|
||||
except Exception as e:
|
||||
current_comp.Print("Error in switching! %s\n" % e.message)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue