Fix #4213. Allow having separate windows to trigger drawing operators.

This commit is contained in:
Dion Moult
2024-01-20 15:06:47 +11:00
parent 3d19d4d319
commit d1f90db707
2 changed files with 13 additions and 10 deletions
+8 -1
View File
@@ -166,6 +166,13 @@ class Blender(blenderbim.core.tool.Blender):
bpy.context.window_manager.popup_menu(message_ui, title=message_type.capitalize(), icon=message_type)
@classmethod
def get_view3d_area(cls):
for window in bpy.context.window_manager.windows:
for area in window.screen.areas:
if area.type == "VIEW_3D":
return area
@classmethod
def get_blender_prop_default_value(cls, props, prop_name):
prop_bl_rna = props.bl_rna.properties[prop_name]
@@ -184,7 +191,7 @@ class Blender(blenderbim.core.tool.Blender):
It's a bit naive since it's just taking the first available `VIEW_3D` area
when in real life you can have a couple of those but should work for the most cases.
"""
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
area = cls.get_view3d_area()
region = next(region for region in area.regions if region.type == "WINDOW")
space = next(space for space in area.spaces if space.type == "VIEW_3D")
context_override = {"area": area, "region": region, "space_data": space}
+5 -9
View File
@@ -1592,12 +1592,8 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def is_drawing_active(cls):
camera = bpy.context.scene.camera
return (
camera
and camera.type == "CAMERA"
and camera.BIMObjectProperties.ifc_definition_id
and any(a.type == "VIEW_3D" for a in bpy.context.screen.areas)
)
area = tool.Blender.get_view3d_area()
return camera and camera.type == "CAMERA" and camera.BIMObjectProperties.ifc_definition_id and area
@classmethod
def is_camera_orthographic(cls):
@@ -1614,7 +1610,7 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def activate_drawing(cls, camera):
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
area = tool.Blender.get_view3d_area()
is_local_view = area.spaces[0].local_view is not None
if is_local_view:
bpy.ops.view3d.localview()
@@ -1742,8 +1738,8 @@ class Drawing(blenderbim.core.tool.Drawing):
local_x = [v.x for v in local_bbox]
local_y = [v.y for v in local_bbox]
local_z = [v.z for v in local_bbox]
aabb1_min = (-x/2, -y/2, -clip_end)
aabb1_max = (x/2, y/2, -clip_start)
aabb1_min = (-x / 2, -y / 2, -clip_end)
aabb1_max = (x / 2, y / 2, -clip_start)
aabb2_min = (min(local_x), min(local_y), min(local_z))
aabb2_max = (max(local_x), max(local_y), max(local_z))
for i in range(3):