Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 18 additions and 10 deletions
Showing only changes of commit 2b949d51e3 - Show all commits

View File

@ -242,6 +242,7 @@ def init_modifiers(scene, obj, use_default_owner: bool):
def transfer_modifier(modifier_name, target_obj, source_obj):
# remove old and sync existing modifiers
context = bpy.context
scene = context.scene
old_mod = target_obj.modifiers.get(modifier_name)
if old_mod:
target_obj.modifiers.remove(old_mod)
@ -257,7 +258,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
for target_mod_i, target_mod in enumerate(target_obj.modifiers):
if target_mod.name == name_prev:
idx = target_mod_i + 1
with override_obj_visability(obj=target_obj):
with override_obj_visability(obj=target_obj, scene=scene):
with context.temp_override(object=target_obj):
bpy.ops.object.modifier_move_to_index(
modifier=mod_new.name, index=idx
@ -274,7 +275,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
if not mod.is_bound:
continue
for i in range(2):
with override_obj_visability(obj=target_obj):
with override_obj_visability(obj=target_obj, scene=scene):
with context.temp_override(
object=target_obj, active_object=target_obj
):
@ -283,7 +284,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
if not mod.is_bound:
continue
for i in range(2):
with override_obj_visability(obj=target_obj):
with override_obj_visability(obj=target_obj, scene=scene):
with context.temp_override(
object=target_obj, active_object=target_obj
):
@ -292,7 +293,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
if not mod.is_bind:
continue
for i in range(2):
with override_obj_visability(obj=target_obj):
with override_obj_visability(obj=target_obj, scene=scene):
with context.temp_override(
object=target_obj, active_object=target_obj
):
@ -358,7 +359,7 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
idx = target_mod_i + 1
if idx != i:
with override_obj_visability(obj=target_obj):
with override_obj_visability(obj=target_obj, scene=context.scene):
with context.temp_override(object=target_obj):
bpy.ops.constraint.move_to_index(
constraint=constraint_new.name, index=idx

View File

@ -12,7 +12,14 @@ def get_visibility_driver(obj) -> Optional[bpy.types.FCurve]:
@contextlib.contextmanager
def override_obj_visability(obj):
def override_obj_visability(obj: bpy.types.Object, scene: bpy.types.Scene):
"""Temporarily Change the Visability of an Object so an bpy.ops or other
function that requires the object to be visable can be called.
Args:
obj (bpy.types.Object): Object to un-hide
scene (bpy.types.Scene): Scene Object is in
"""
hide = obj.hide_get() # eye icon
hide_viewport = obj.hide_viewport # hide viewport
select = obj.hide_select # selectable
@ -29,9 +36,9 @@ def override_obj_visability(obj):
driver.mute = True
assigned_to_scene_root = False
if obj.name not in bpy.context.scene.collection.objects:
if obj.name not in scene.collection.objects:
assigned_to_scene_root = True
bpy.context.scene.collection.objects.link(obj) # TODO Pass Current Scene
scene.collection.objects.link(obj)
yield
@ -42,5 +49,5 @@ def override_obj_visability(obj):
if driver:
driver.mute = driver_mute
if assigned_to_scene_root and obj.name in bpy.context.scene.collection.objects:
bpy.context.scene.collection.objects.unlink(obj) # TODO Pass Current Scene
if assigned_to_scene_root and obj.name in scene.collection.objects:
scene.collection.objects.unlink(obj)