mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Get the selection when creating the instance
This commit is contained in:
parent
58c9664f7e
commit
821b478830
1 changed files with 27 additions and 0 deletions
|
|
@ -15,6 +15,8 @@ class CreateBlendScene(plugin.Creator):
|
|||
family = "blendScene"
|
||||
icon = "cubes"
|
||||
|
||||
maintain_selection = False
|
||||
|
||||
def process(self):
|
||||
""" Run the creator on Blender main thread"""
|
||||
mti = ops.MainThreadItem(self._process)
|
||||
|
|
@ -38,4 +40,29 @@ class CreateBlendScene(plugin.Creator):
|
|||
self.data['task'] = get_current_task_name()
|
||||
lib.imprint(asset_group, self.data)
|
||||
|
||||
try:
|
||||
area = next(
|
||||
area for area in bpy.context.window.screen.areas
|
||||
if area.type == 'OUTLINER')
|
||||
region = next(
|
||||
region for region in area.regions
|
||||
if region.type == 'WINDOW')
|
||||
except StopIteration as e:
|
||||
raise RuntimeError("Could not find outliner. An outliner space "
|
||||
"must be in the main Blender window.") from e
|
||||
|
||||
with bpy.context.temp_override(
|
||||
window=bpy.context.window,
|
||||
area=area,
|
||||
region=region,
|
||||
screen=bpy.context.window.screen
|
||||
):
|
||||
ids = bpy.context.selected_ids
|
||||
|
||||
for id in ids:
|
||||
if isinstance(id, bpy.types.Collection):
|
||||
asset_group.children.link(id)
|
||||
elif isinstance(id, bpy.types.Object):
|
||||
asset_group.objects.link(id)
|
||||
|
||||
return asset_group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue