From 5a1889e413273bf3dbdbf2ee2d4eb4f080f397e2 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Wed, 7 Apr 2021 16:49:27 +0100 Subject: [PATCH] Fix for the workflow between Blender and Unreal for OpenPype 3.0 --- openpype/hooks/pre_python2_vendor.py | 2 +- openpype/hosts/blender/api/__init__.py | 13 +++++++++++-- openpype/hosts/blender/plugins/load/load_layout.py | 5 ++++- openpype/hosts/unreal/__init__.py | 0 .../hosts/unreal/hooks/pre_workfile_preparation.py | 8 ++++---- openpype/lib/avalon_context.py | 1 + .../ftrack/launch_hooks/pre_python2_vendor.py | 2 +- 7 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 openpype/hosts/unreal/__init__.py diff --git a/openpype/hooks/pre_python2_vendor.py b/openpype/hooks/pre_python2_vendor.py index 7aaf713dec..815682fef8 100644 --- a/openpype/hooks/pre_python2_vendor.py +++ b/openpype/hooks/pre_python2_vendor.py @@ -6,7 +6,7 @@ class PrePython2Vendor(PreLaunchHook): """Prepend python 2 dependencies for py2 hosts.""" # WARNING This hook will probably be deprecated in OpenPype 3 - kept for test order = 10 - app_groups = ["hiero", "nuke", "nukex"] + app_groups = ["hiero", "nuke", "nukex", "unreal"] def execute(self): # Prepare vendor dir path diff --git a/openpype/hosts/blender/api/__init__.py b/openpype/hosts/blender/api/__init__.py index 55c5b63f60..c5b0a44072 100644 --- a/openpype/hosts/blender/api/__init__.py +++ b/openpype/hosts/blender/api/__init__.py @@ -51,9 +51,18 @@ def set_start_end_frames(): "name": asset_name }) - bpy.context.scene.frame_start = asset_doc["data"]["frameStart"] - bpy.context.scene.frame_end = asset_doc["data"]["frameEnd"] + # Default frame start/end + frameStart = 0 + frameEnd = 100 + # Check if frameStart/frameEnd are set + if asset_doc["data"]["frameStart"]: + frameStart = asset_doc["data"]["frameStart"] + if asset_doc["data"]["frameEnd"]: + frameEnd = asset_doc["data"]["frameEnd"] + + bpy.context.scene.frame_start = frameStart + bpy.context.scene.frame_end = frameEnd def on_new(arg1, arg2): set_start_end_frames() diff --git a/openpype/hosts/blender/plugins/load/load_layout.py b/openpype/hosts/blender/plugins/load/load_layout.py index 73b12d8c25..f1f2fdcddd 100644 --- a/openpype/hosts/blender/plugins/load/load_layout.py +++ b/openpype/hosts/blender/plugins/load/load_layout.py @@ -292,6 +292,9 @@ class UnrealLayoutLoader(plugin.AssetLoader): icon = "code-fork" color = "orange" + animation_creator_name = "CreateAnimation" + setdress_creator_name = "CreateSetDress" + def _remove_objects(self, objects): for obj in list(objects): if obj.type == 'ARMATURE': @@ -368,7 +371,7 @@ class UnrealLayoutLoader(plugin.AssetLoader): location.get('z') ) obj.rotation_euler = ( - rotation.get('x'), + rotation.get('x') + math.pi / 2, -rotation.get('y'), -rotation.get('z') ) diff --git a/openpype/hosts/unreal/__init__.py b/openpype/hosts/unreal/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/openpype/hosts/unreal/hooks/pre_workfile_preparation.py b/openpype/hosts/unreal/hooks/pre_workfile_preparation.py index 5945d0486b..c698be63de 100644 --- a/openpype/hosts/unreal/hooks/pre_workfile_preparation.py +++ b/openpype/hosts/unreal/hooks/pre_workfile_preparation.py @@ -23,8 +23,8 @@ class UnrealPrelaunchHook(PreLaunchHook): def execute(self): asset_name = self.data["asset_name"] task_name = self.data["task_name"] - workdir = self.env["AVALON_WORKDIR"] - engine_version = self.app_name.split("_")[-1] + workdir = self.launch_context.env["AVALON_WORKDIR"] + engine_version = self.app_name.split("_")[-1].replace("-", ".") unreal_project_name = f"{asset_name}_{task_name}" # Unreal is sensitive about project names longer then 20 chars @@ -81,8 +81,8 @@ class UnrealPrelaunchHook(PreLaunchHook): # Set "AVALON_UNREAL_PLUGIN" to current process environment for # execution of `create_unreal_project` env_key = "AVALON_UNREAL_PLUGIN" - if self.env.get(env_key): - os.environ[env_key] = self.env[env_key] + if self.launch_context.env.get(env_key): + os.environ[env_key] = self.launch_context.env[env_key] unreal_lib.create_unreal_project( unreal_project_name, diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 1f7c693b85..2d8726352a 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -1123,6 +1123,7 @@ class BuildWorkfile: return output +@with_avalon def get_creator_by_name(creator_name, case_sensitive=False): """Find creator plugin by name. diff --git a/openpype/modules/ftrack/launch_hooks/pre_python2_vendor.py b/openpype/modules/ftrack/launch_hooks/pre_python2_vendor.py index 7826d833ac..f14857bc98 100644 --- a/openpype/modules/ftrack/launch_hooks/pre_python2_vendor.py +++ b/openpype/modules/ftrack/launch_hooks/pre_python2_vendor.py @@ -9,7 +9,7 @@ class PrePython2Support(PreLaunchHook): Path to vendor modules is added to the beggining of PYTHONPATH. """ # There will be needed more granular filtering in future - app_groups = ["maya", "nuke", "nukex", "hiero", "nukestudio"] + app_groups = ["maya", "nuke", "nukex", "hiero", "nukestudio", "unreal"] def execute(self): # Prepare vendor dir path