From 1ebc6d351848f60895c8e1175851b099aa758e70 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Tue, 30 Jun 2020 16:34:20 +0100 Subject: [PATCH 1/3] Set start and end frames when opening file --- pype/hosts/blender/__init__.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pype/hosts/blender/__init__.py b/pype/hosts/blender/__init__.py index a6d3cd82ef..52cc53f05c 100644 --- a/pype/hosts/blender/__init__.py +++ b/pype/hosts/blender/__init__.py @@ -2,9 +2,11 @@ import os import sys import traceback -from avalon import api as avalon +from avalon import api as avalon, pipeline, blender from pyblish import api as pyblish +import bpy + from pype import PLUGINS_DIR PUBLISH_PATH = os.path.join(PLUGINS_DIR, "blender", "publish") @@ -25,6 +27,8 @@ def install(): avalon.register_plugin_path(avalon.Loader, str(LOAD_PATH)) avalon.register_plugin_path(avalon.Creator, str(CREATE_PATH)) + avalon.on("open", on_open) + def uninstall(): """Uninstall Blender configuration for Avalon.""" @@ -32,3 +36,17 @@ def uninstall(): pyblish.deregister_plugin_path(str(PUBLISH_PATH)) avalon.deregister_plugin_path(avalon.Loader, str(LOAD_PATH)) avalon.deregister_plugin_path(avalon.Creator, str(CREATE_PATH)) + + +def on_open(arg1, arg2): + + from avalon import io + + asset_name = io.Session["AVALON_ASSET"] + asset_doc = io.find_one({ + "type": "asset", + "name": asset_name + }) + + bpy.context.scene.frame_start = asset_doc["data"]["frameStart"] + bpy.context.scene.frame_end = asset_doc["data"]["frameEnd"] From 138131d7e0e35699090ad613e110e4effe0c3d2f Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Wed, 1 Jul 2020 11:09:34 +0100 Subject: [PATCH 2/3] Set start and end frames when opening Blender --- pype/hosts/blender/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pype/hosts/blender/__init__.py b/pype/hosts/blender/__init__.py index 52cc53f05c..498796a36a 100644 --- a/pype/hosts/blender/__init__.py +++ b/pype/hosts/blender/__init__.py @@ -27,6 +27,7 @@ def install(): avalon.register_plugin_path(avalon.Loader, str(LOAD_PATH)) avalon.register_plugin_path(avalon.Creator, str(CREATE_PATH)) + avalon.on("new", on_new) avalon.on("open", on_open) @@ -38,8 +39,7 @@ def uninstall(): avalon.deregister_plugin_path(avalon.Creator, str(CREATE_PATH)) -def on_open(arg1, arg2): - +def set_start_end_frames(): from avalon import io asset_name = io.Session["AVALON_ASSET"] @@ -50,3 +50,11 @@ def on_open(arg1, arg2): bpy.context.scene.frame_start = asset_doc["data"]["frameStart"] bpy.context.scene.frame_end = asset_doc["data"]["frameEnd"] + + +def on_new(arg1, arg2): + set_start_end_frames() + + +def on_open(arg1, arg2): + set_start_end_frames() From b38150173a22761cc5337977b37db2fca45864e6 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Fri, 3 Jul 2020 09:35:29 +0100 Subject: [PATCH 3/3] Hound fixes --- pype/hosts/blender/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/hosts/blender/__init__.py b/pype/hosts/blender/__init__.py index 498796a36a..dafeca5107 100644 --- a/pype/hosts/blender/__init__.py +++ b/pype/hosts/blender/__init__.py @@ -2,7 +2,7 @@ import os import sys import traceback -from avalon import api as avalon, pipeline, blender +from avalon import api as avalon from pyblish import api as pyblish import bpy