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): diff --git a/colorbleed/scripts/fusion_switch_shot.py b/colorbleed/scripts/fusion_switch_shot.py index 07bbafa057..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.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)