diff --git a/client/ayon_openrv/addon.py b/client/ayon_openrv/addon.py index 9c6fa84..8b3c972 100644 --- a/client/ayon_openrv/addon.py +++ b/client/ayon_openrv/addon.py @@ -6,7 +6,6 @@ OPENRV_ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) - class OpenRVAddon(AYONAddon, IHostAddon, IPluginPaths): name = "openrv" host_name = "openrv" @@ -35,7 +34,7 @@ def get_load_plugin_paths(self, host_name): # inside OpenRV return [os.path.join(loaders_dir, "openrv")] - def add_implementation_envs(self, env, app): + def add_implementation_envs(self, env, _app): """Modify environments to contain all required for implementation.""" # Set default environments if are not set via settings defaults = { diff --git a/client/ayon_openrv/plugins/load/openrv/load_frames.py b/client/ayon_openrv/plugins/load/openrv/load_frames.py index 14b4e7a..9ab17c8 100644 --- a/client/ayon_openrv/plugins/load/openrv/load_frames.py +++ b/client/ayon_openrv/plugins/load/openrv/load_frames.py @@ -28,7 +28,6 @@ class FramesLoader(load.LoaderPlugin): color = "orange" def load(self, context, name=None, namespace=None, data=None): - filepath = self._format_path(context) # Command fails on unicode so we must force it to be strings filepath = str(filepath) @@ -37,6 +36,7 @@ def load(self, context, name=None, namespace=None, data=None): namespace = namespace if namespace else context["folder"]["name"] loaded_node = rv.commands.addSourceVerbose([filepath]) + self.log.debug(f"Loaded node: {loaded_node}") # update colorspace self.set_representation_colorspace(loaded_node, @@ -97,22 +97,30 @@ def _get_sequence_range(self, context): """ repre_entity = context["representation"] + version_entity = context["version"] # Only images may be sequences, not videos ext = repre_entity["context"].get("ext") or repre_entity["name"] if f".{ext}" not in IMAGE_EXTENSIONS: + self.log.debug(f"Extension {ext} not in IMAGE_EXTENSIONS") return - repre_attribs = repre_entity["attrib"] - # Frame range can be set on version or representation. - # When set on representation it overrides version data. - - repre_frame_start = repre_attribs.get("frameStart") - repre_frame_end = repre_attribs.get("frameEnd") - if repre_frame_start is not None and repre_frame_end is not None: - if repre_frame_start != repre_frame_end: - return repre_frame_start, repre_frame_end - # Single frame + # Check version attributes first as they should have the correct frame range + + version_attribs = version_entity["attrib"] + frame_start = version_attribs.get("frameStart") + frame_end = version_attribs.get("frameEnd") + + # If not in version attributes, check representation attributes + if frame_start is None or frame_end is None: + repre_attribs = repre_entity["attrib"] + frame_start = repre_attribs.get("frameStart") + frame_end = repre_attribs.get("frameEnd") + + if frame_start is not None and frame_end is not None: + if frame_start != frame_end: + self.log.debug(f"Using frame range: {frame_start}-{frame_end}") + return frame_start, frame_end return # Fallback for image sequence that does not have frame start and frame @@ -137,7 +145,6 @@ def _format_path(self, context): /path/to/sequence.1001-1010#.exr """ - sequence_range = self._get_sequence_range(context) if not sequence_range: return get_representation_path_from_context(context) @@ -146,6 +153,7 @@ def _format_path(self, context): representation = context["representation"] if not representation["attrib"].get("template"): # No template to find token locations for + self.log.debug(f"No template found, using direct path") return get_representation_path_from_context(context) def _placeholder(key): @@ -161,6 +169,7 @@ def _placeholder(key): tokens = { "frame": f"{start}-{end}#", } + self.log.debug(f"Using tokens: {tokens}") has_tokens = False repre_context = representation["context"] for key, _token in tokens.items(): @@ -170,12 +179,14 @@ def _placeholder(key): # Replace with our custom template that has the tokens set path = get_representation_path_from_context(context) + self.log.debug(f"Initial path with placeholders: {path}") if has_tokens: for key, token in tokens.items(): if key in repre_context: path = path.replace(_placeholder(key), token) - + + self.log.debug(f"Final formatted path: {path}") return path def set_representation_colorspace(self, node, representation):