From 0b7ce6857130bfc00c7f56ef148cecc87b016817 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Sat, 21 Jul 2018 13:21:28 +0200 Subject: [PATCH 1/3] Fix bug in code so it actually checks whether path is absolute --- colorbleed/scripts/fusion_switch_shot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorbleed/scripts/fusion_switch_shot.py b/colorbleed/scripts/fusion_switch_shot.py index 07bbafa057..5fcfa638d6 100644 --- a/colorbleed/scripts/fusion_switch_shot.py +++ b/colorbleed/scripts/fusion_switch_shot.py @@ -158,7 +158,7 @@ def switch(asset_name, filepath=None, new=True): """ # Ensure filename is absolute - if not os.path.abspath(filepath): + if not os.path.isabs(filepath): filepath = os.path.abspath(filepath) # Get current project From 40640eb598bb79d4d2d29a2e257dc8c1741aa4b6 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Sat, 21 Jul 2018 14:50:58 +0200 Subject: [PATCH 2/3] Fix FUS-48 loader update not offsetting correctly to its frame time upon update/switch --- .../plugins/fusion/load/load_sequence.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/colorbleed/plugins/fusion/load/load_sequence.py b/colorbleed/plugins/fusion/load/load_sequence.py index 6d3d743c8a..81313992ed 100644 --- a/colorbleed/plugins/fusion/load/load_sequence.py +++ b/colorbleed/plugins/fusion/load/load_sequence.py @@ -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): From 2dfbbeb093d8f20d795f728501ebb66d7fa005a4 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Sat, 21 Jul 2018 14:52:38 +0200 Subject: [PATCH 3/3] Improve absolute filename check to be explicit - Also move asset assertion up (micro-optimization) --- colorbleed/scripts/fusion_switch_shot.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/colorbleed/scripts/fusion_switch_shot.py b/colorbleed/scripts/fusion_switch_shot.py index 5fcfa638d6..4254d6c4ce 100644 --- a/colorbleed/scripts/fusion_switch_shot.py +++ b/colorbleed/scripts/fusion_switch_shot.py @@ -157,19 +157,22 @@ def switch(asset_name, filepath=None, new=True): """ - # Ensure filename is absolute - if not os.path.isabs(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)