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.
Showing only changes of commit 9e21359066 - Show all commits

View File

@ -0,0 +1,46 @@
import bpy
import contextlib
from typing import Optional
def get_visibility_driver(obj) -> Optional[bpy.types.FCurve]:
obj = bpy.data.objects.get(obj.name)
assert obj, "Object was renamed while its visibility was being ensured?"
if hasattr(obj, "animation_data") and obj.animation_data:
return obj.animation_data.drivers.find("hide_viewport")
@contextlib.contextmanager
def override_obj_visability(obj):
hide = obj.hide_get() # eye icon
hide_viewport = obj.hide_viewport # hide viewport
select = obj.hide_select # selectable
driver = get_visibility_driver(obj)
if driver:
driver_mute = driver.mute
try:
obj.hide_set(False)
obj.hide_viewport = False
obj.hide_select = False
if driver:
driver.mute = True
assigned_to_scene_root = False
if obj.name not in bpy.context.scene.collection.objects:
assigned_to_scene_root = True
bpy.context.scene.collection.objects.link(obj) # TODO Pass Current Scene
yield
finally:
obj.hide_set(hide)
obj.hide_viewport = hide_viewport
obj.hide_select = select
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