Skip to content

Commit c7b3331

Browse files
committed
switch to external styles for rendered shading in viewport
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
1 parent 7c0c934 commit c7b3331

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/blenderbim/blenderbim/bim/handler.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,34 @@ def get_application_version():
259259
)
260260

261261

262+
def viewport_shading_changed_callback(area):
263+
shading = area.spaces.active.shading.type
264+
if shading == "RENDERED":
265+
bpy.context.scene.BIMStylesProperties.active_style_type = "External"
266+
267+
262268
@persistent
263269
def setDefaultProperties(scene):
264270
global global_subscription_owner
265271
active_object_key = bpy.types.LayerObjects, "active"
266272
bpy.msgbus.subscribe_rna(
267273
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
268274
)
275+
276+
# subscribe to changes in viewport shading mode
277+
# NOTE: couldn't find a way to make it work for new areas too
278+
# it starts working for them after blender restart though
279+
for screen in bpy.data.screens:
280+
for area in screen.areas:
281+
if area.type != "VIEW_3D":
282+
continue
283+
shading = area.spaces.active.shading
284+
key = shading.path_resolve("type", False)
285+
286+
bpy.msgbus.subscribe_rna(
287+
key=key, owner=global_subscription_owner, args=(area,), notify=viewport_shading_changed_callback
288+
)
289+
269290
ifcopenshell.api.owner.settings.get_user = lambda ifc: core_owner.get_user(tool.Owner)
270291
ifcopenshell.api.owner.settings.get_application = get_application
271292
AuthoringData.type_thumbnails = {}

0 commit comments

Comments
 (0)