Skip to content

Commit

Permalink
switch to external styles for rendered shading in viewport
Browse files Browse the repository at this point in the history
Unfortunately I couldn't find a way to make it work with areas that user created during current blender session. But new areas will have this feature too after blender restart
  • Loading branch information
Andrej730 committed Jun 12, 2023
1 parent 7c0c934 commit c7b3331
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/blenderbim/blenderbim/bim/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,34 @@ def get_application_version():
)


def viewport_shading_changed_callback(area):
shading = area.spaces.active.shading.type
if shading == "RENDERED":
bpy.context.scene.BIMStylesProperties.active_style_type = "External"


@persistent
def setDefaultProperties(scene):
global global_subscription_owner
active_object_key = bpy.types.LayerObjects, "active"
bpy.msgbus.subscribe_rna(
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
)

# subscribe to changes in viewport shading mode
# NOTE: couldn't find a way to make it work for new areas too
# it starts working for them after blender restart though
for screen in bpy.data.screens:
for area in screen.areas:
if area.type != "VIEW_3D":
continue
shading = area.spaces.active.shading
key = shading.path_resolve("type", False)

bpy.msgbus.subscribe_rna(
key=key, owner=global_subscription_owner, args=(area,), notify=viewport_shading_changed_callback
)

ifcopenshell.api.owner.settings.get_user = lambda ifc: core_owner.get_user(tool.Owner)
ifcopenshell.api.owner.settings.get_application = get_application
AuthoringData.type_thumbnails = {}

0 comments on commit c7b3331

Please sign in to comment.