mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Avoid need for executing in main thread by just not using bpy.ops functions.
I also skipped the "keep_transform" part of the functionality since it's redundant because the created asset group is always at origin by default, and thus needs no matrix inverse computations.
This commit is contained in:
parent
6e89f33014
commit
a2a47787db
4 changed files with 13 additions and 31 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import bpy
|
||||
|
||||
from openpype.hosts.blender.api import plugin, lib, ops
|
||||
from openpype.hosts.blender.api import plugin, lib
|
||||
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES
|
||||
|
||||
|
||||
|
|
@ -17,7 +17,6 @@ class CreateCamera(plugin.BaseCreator):
|
|||
|
||||
create_as_asset_group = True
|
||||
|
||||
@ops.execute_function_in_main_thread
|
||||
def create(
|
||||
self, subset_name: str, instance_data: dict, pre_create_data: dict
|
||||
):
|
||||
|
|
@ -27,13 +26,10 @@ class CreateCamera(plugin.BaseCreator):
|
|||
instance_data,
|
||||
pre_create_data)
|
||||
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
if pre_create_data.get("use_selection"):
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
selected = lib.get_selection()
|
||||
for obj in selected:
|
||||
obj.select_set(True)
|
||||
selected.append(asset_group)
|
||||
bpy.ops.object.parent_set(keep_transform=True)
|
||||
for obj in lib.get_selection():
|
||||
obj.parent = asset_group
|
||||
else:
|
||||
plugin.deselect_all()
|
||||
camera = bpy.data.cameras.new(subset_name)
|
||||
|
|
@ -42,9 +38,7 @@ class CreateCamera(plugin.BaseCreator):
|
|||
instances = bpy.data.collections.get(AVALON_INSTANCES)
|
||||
instances.objects.link(camera_obj)
|
||||
|
||||
camera_obj.select_set(True)
|
||||
asset_group.select_set(True)
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
bpy.ops.object.parent_set(keep_transform=True)
|
||||
camera_obj.parent = asset_group
|
||||
|
||||
return asset_group
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ class CreateLayout(plugin.BaseCreator):
|
|||
# Add selected objects to instance
|
||||
if pre_create_data.get("use_selection"):
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
selected = lib.get_selection()
|
||||
for obj in selected:
|
||||
obj.select_set(True)
|
||||
selected.append(asset_group)
|
||||
bpy.ops.object.parent_set(keep_transform=True)
|
||||
for obj in lib.get_selection():
|
||||
obj.parent = asset_group
|
||||
|
||||
return asset_group
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import bpy
|
||||
|
||||
from openpype.hosts.blender.api import plugin, lib, ops
|
||||
from openpype.hosts.blender.api import plugin, lib
|
||||
|
||||
|
||||
class CreateModel(plugin.BaseCreator):
|
||||
|
|
@ -16,7 +16,6 @@ class CreateModel(plugin.BaseCreator):
|
|||
|
||||
create_as_asset_group = True
|
||||
|
||||
@ops.execute_function_in_main_thread
|
||||
def create(
|
||||
self, subset_name: str, instance_data: dict, pre_create_data: dict
|
||||
):
|
||||
|
|
@ -27,11 +26,7 @@ class CreateModel(plugin.BaseCreator):
|
|||
# Add selected objects to instance
|
||||
if pre_create_data.get("use_selection"):
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
selected = lib.get_selection()
|
||||
for obj in selected:
|
||||
obj.select_set(True)
|
||||
selected.append(asset_group)
|
||||
|
||||
bpy.ops.object.parent_set(keep_transform=True)
|
||||
for obj in lib.get_selection():
|
||||
obj.parent = asset_group
|
||||
|
||||
return asset_group
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import bpy
|
||||
|
||||
from openpype.hosts.blender.api import plugin, lib, ops
|
||||
from openpype.hosts.blender.api import plugin, lib
|
||||
|
||||
|
||||
class CreateRig(plugin.BaseCreator):
|
||||
|
|
@ -16,7 +16,6 @@ class CreateRig(plugin.BaseCreator):
|
|||
|
||||
create_as_asset_group = True
|
||||
|
||||
@ops.execute_function_in_main_thread
|
||||
def create(
|
||||
self, subset_name: str, instance_data: dict, pre_create_data: dict
|
||||
):
|
||||
|
|
@ -27,10 +26,7 @@ class CreateRig(plugin.BaseCreator):
|
|||
# Add selected objects to instance
|
||||
if pre_create_data.get("use_selection"):
|
||||
bpy.context.view_layer.objects.active = asset_group
|
||||
selected = lib.get_selection()
|
||||
for obj in selected:
|
||||
obj.select_set(True)
|
||||
selected.append(asset_group)
|
||||
bpy.ops.object.parent_set(keep_transform=True)
|
||||
for obj in lib.get_selection():
|
||||
obj.parent = asset_group
|
||||
|
||||
return asset_group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue