Updated based on feedback from @brunoperdigao

This commit is contained in:
falken10
2025-05-31 11:55:17 +02:00
committed by Bruno Perdigão
parent 38fe7fea65
commit a686d70908
5 changed files with 10 additions and 15 deletions
+3 -1
View File
@@ -30,7 +30,7 @@ from bonsai.bim.ifc import IfcStore
from bonsai.bim.module.model.data import AuthoringData from bonsai.bim.module.model.data import AuthoringData
from bonsai.bim.module.aggregate.decorator import AggregateDecorator from bonsai.bim.module.aggregate.decorator import AggregateDecorator
from bonsai.bim.module.georeference.decorator import GeoreferenceDecorator from bonsai.bim.module.georeference.decorator import GeoreferenceDecorator
from bonsai.bim.module.model.decorator import WallAxisDecorator, SlabDirectionDecorator from bonsai.bim.module.model.decorator import WallAxisDecorator, SlabDirectionDecorator, BoundingBoxDecorator
from bonsai.bim.module.nest.decorator import NestDecorator from bonsai.bim.module.nest.decorator import NestDecorator
from mathutils import Vector from mathutils import Vector
from math import cos from math import cos
@@ -409,6 +409,8 @@ def load_post(scene):
WallAxisDecorator.install(bpy.context) WallAxisDecorator.install(bpy.context)
if model_props.show_slab_direction: if model_props.show_slab_direction:
SlabDirectionDecorator.install(bpy.context) SlabDirectionDecorator.install(bpy.context)
if model_props.show_bounding_box:
BoundingBoxDecorator.install(bpy.context)
if preferences.should_use_snap and (scene := bpy.context.scene): if preferences.should_use_snap and (scene := bpy.context.scene):
# Snapping is off by default in Blender, but in BIM, it's more useful to be on # Snapping is off by default in Blender, but in BIM, it's more useful to be on
+1 -1
View File
@@ -533,7 +533,7 @@ class BIM_PT_derived_coordinates(Panel):
area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None) area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None)
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None) space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None)
if bpy.context.scene.BIMModelProperties.measure_xyz_dimensions: if bpy.context.scene.BIMModelProperties.show_bounding_box:
for axis, icon, idx in [("X", "STRIP_COLOR_01", 0), ("Y", "STRIP_COLOR_04", 1), ("Z", "STRIP_COLOR_05", 2)]: for axis, icon, idx in [("X", "STRIP_COLOR_01", 0), ("Y", "STRIP_COLOR_04", 1), ("Z", "STRIP_COLOR_05", 2)]:
row.label(text="", icon=icon) row.label(text="", icon=icon)
row.prop(context.active_object, "dimensions", text=axis, index=idx) row.prop(context.active_object, "dimensions", text=axis, index=idx)
@@ -21,11 +21,11 @@ import bpy
import blf import blf
import bpy import bpy
import gpu import gpu
import gpu_extras
import bmesh import bmesh
import ifcopenshell import ifcopenshell
import bonsai.tool as tool import bonsai.tool as tool
import math import math
import mathutils
from math import sin, cos, radians from math import sin, cos, radians
from bpy.types import SpaceView3D from bpy.types import SpaceView3D
from bpy_extras import view3d_utils from bpy_extras import view3d_utils
@@ -36,6 +36,7 @@ from typing import Union
from bonsai.bim.module.drawing.helper import format_distance from bonsai.bim.module.drawing.helper import format_distance
from itertools import chain from itertools import chain
from typing import Union, Any from typing import Union, Any
from bpy_extras.view3d_utils import location_3d_to_region_2d
def transparent_color(color, alpha=0.1): def transparent_color(color, alpha=0.1):
@@ -1165,7 +1166,6 @@ class BoundingBoxDecorator:
@staticmethod @staticmethod
def get_combined_bounding_box_corners(objects): def get_combined_bounding_box_corners(objects):
import mathutils
if not objects: if not objects:
return None, None, None return None, None, None
@@ -1216,7 +1216,6 @@ class BoundingBoxDecorator:
@staticmethod @staticmethod
def find_closest_trihedron(corners, edges, region, rv3d): def find_closest_trihedron(corners, edges, region, rv3d):
from bpy_extras.view3d_utils import location_3d_to_region_2d
min_y = float("inf") min_y = float("inf")
best_origin = None best_origin = None
@@ -1259,8 +1258,7 @@ class BoundingBoxDecorator:
self.draw_batch("TRIS", verts, color, [(0, 1, 2), (1, 2, 3)]) self.draw_batch("TRIS", verts, color, [(0, 1, 2), (1, 2, 3)])
def draw_bounding_box_wire_cube(self, context): def draw_bounding_box_wire_cube(self, context):
import gpu
from gpu_extras.batch import batch_for_shader
self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() self.line_shader.bind()
@@ -1285,11 +1283,6 @@ class BoundingBoxDecorator:
self.draw_batch("LINES", [corners[i1], corners[i2]], color) self.draw_batch("LINES", [corners[i1], corners[i2]], color)
def draw_dimension_text(self, context): def draw_dimension_text(self, context):
from bpy_extras.view3d_utils import location_3d_to_region_2d
from bonsai.bim.module.drawing.helper import format_distance
import mathutils
import blf
self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() self.line_shader.bind()
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
+2 -2
View File
@@ -119,7 +119,7 @@ def update_measure_xyz(self: "BIMModelProperties", context: bpy.types.Context) -
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None) if area_3d else None space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None) if area_3d else None
scene = context.scene scene = context.scene
if self.measure_xyz_dimensions: if self.show_bounding_box:
BoundingBoxDecorator.install(context) BoundingBoxDecorator.install(context)
# Save previous state if not already saved # Save previous state if not already saved
if not self.prev_transform_orientation_slot_type: if not self.prev_transform_orientation_slot_type:
@@ -286,7 +286,7 @@ class BIMModelProperties(PropertyGroup):
prev_transform_orientation_slot_type: bpy.props.StringProperty(name="Previous Gizmo Orientation Type") prev_transform_orientation_slot_type: bpy.props.StringProperty(name="Previous Gizmo Orientation Type")
prev_show_gizmo_object_translate: bpy.props.BoolProperty(name="Previous Gizmo Translate") prev_show_gizmo_object_translate: bpy.props.BoolProperty(name="Previous Gizmo Translate")
measure_xyz_dimensions: bpy.props.BoolProperty( show_bounding_box: bpy.props.BoolProperty(
name="Measure XYZ Dimensions", name="Measure XYZ Dimensions",
default=False, default=False,
update=update_measure_xyz update=update_measure_xyz
+1 -1
View File
@@ -1334,7 +1334,7 @@ class BIM_PT_decorators_overlay(Panel):
row = col.row(align=True) row = col.row(align=True)
row.prop(model_props, "show_slab_direction", text="Slab Direction") row.prop(model_props, "show_slab_direction", text="Slab Direction")
row = col.row(align=True) row = col.row(align=True)
row.prop(model_props, "measure_xyz_dimensions", text="Bounding Box Dimensions") row.prop(model_props, "show_bounding_box", text="Bounding Box Dimensions")
row = col.row(align=True) row = col.row(align=True)
row.prop(model_props, "show_cut_decorator", text="Cut Decorator") row.prop(model_props, "show_cut_decorator", text="Cut Decorator")
row.prop(model_props, "show_cut_decorator_fill", text="Fill Cut Decorator") row.prop(model_props, "show_cut_decorator_fill", text="Fill Cut Decorator")