Added blendScene family

This commit is contained in:
Simone Barbieri 2023-07-14 12:05:49 +01:00
parent 585df83135
commit aaafb9ccf2
5 changed files with 57 additions and 4 deletions

View file

@ -0,0 +1,51 @@
"""Create a Blender scene asset."""
import bpy
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES
class CreateBlendScene(plugin.Creator):
"""Generic group of assets"""
name = "blendScene"
label = "Blender Scene"
family = "blendScene"
icon = "cubes"
def process(self):
""" Run the creator on Blender main thread"""
mti = ops.MainThreadItem(self._process)
ops.execute_in_main_thread(mti)
def _process(self):
# Get Instance Container or create it if it does not exist
instances = bpy.data.collections.get(AVALON_INSTANCES)
if not instances:
instances = bpy.data.collections.new(name=AVALON_INSTANCES)
bpy.context.scene.collection.children.link(instances)
# Create instance object
asset = self.data["asset"]
subset = self.data["subset"]
name = plugin.asset_name(asset, subset)
asset_group = bpy.data.objects.new(name=name, object_data=None)
asset_group.empty_display_type = 'SINGLE_ARROW'
instances.objects.link(asset_group)
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)
# Add selected objects to instance
if (self.options or {}).get("useSelection"):
bpy.context.view_layer.objects.active = asset_group
selected = lib.get_selection()
for obj in selected:
if obj.parent in selected:
obj.select_set(False)
continue
selected.append(asset_group)
bpy.ops.object.parent_set(keep_transform=True)
return asset_group

View file

@ -20,7 +20,7 @@ from openpype.hosts.blender.api.pipeline import (
class BlendLoader(plugin.AssetLoader):
"""Load assets from a .blend file."""
families = ["model", "rig", "layout", "camera"]
families = ["model", "rig", "layout", "camera", "blendScene"]
representations = ["blend"]
label = "Append Blend"

View file

@ -10,7 +10,7 @@ class ExtractBlend(publish.Extractor):
label = "Extract Blend"
hosts = ["blender"]
families = ["model", "camera", "rig", "action", "layout"]
families = ["model", "camera", "rig", "action", "layout", "blendScene"]
optional = True
def process(self, instance):

View file

@ -137,7 +137,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
"mvUsdOverride",
"simpleUnrealTexture",
"online",
"uasset"
"uasset",
"blendScene"
]
default_template_name = "publish"

View file

@ -54,7 +54,8 @@
"camera",
"rig",
"action",
"layout"
"layout",
"blendScene"
]
},
"ExtractFBX": {