mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Updated based on feedback from @brunoperdigao
This commit is contained in:
@@ -30,7 +30,7 @@ from bonsai.bim.ifc import IfcStore
|
||||
from bonsai.bim.module.model.data import AuthoringData
|
||||
from bonsai.bim.module.aggregate.decorator import AggregateDecorator
|
||||
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 mathutils import Vector
|
||||
from math import cos
|
||||
@@ -409,6 +409,8 @@ def load_post(scene):
|
||||
WallAxisDecorator.install(bpy.context)
|
||||
if model_props.show_slab_direction:
|
||||
SlabDirectionDecorator.install(bpy.context)
|
||||
if model_props.show_bounding_box:
|
||||
BoundingBoxDecorator.install(bpy.context)
|
||||
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
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)]:
|
||||
row.label(text="", icon=icon)
|
||||
row.prop(context.active_object, "dimensions", text=axis, index=idx)
|
||||
|
||||
@@ -21,11 +21,11 @@ import bpy
|
||||
import blf
|
||||
import bpy
|
||||
import gpu
|
||||
import gpu_extras
|
||||
import bmesh
|
||||
import ifcopenshell
|
||||
import bonsai.tool as tool
|
||||
import math
|
||||
import mathutils
|
||||
from math import sin, cos, radians
|
||||
from bpy.types import SpaceView3D
|
||||
from bpy_extras import view3d_utils
|
||||
@@ -36,6 +36,7 @@ from typing import Union
|
||||
from bonsai.bim.module.drawing.helper import format_distance
|
||||
from itertools import chain
|
||||
from typing import Union, Any
|
||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||
|
||||
|
||||
def transparent_color(color, alpha=0.1):
|
||||
@@ -1165,7 +1166,6 @@ class BoundingBoxDecorator:
|
||||
|
||||
@staticmethod
|
||||
def get_combined_bounding_box_corners(objects):
|
||||
import mathutils
|
||||
|
||||
if not objects:
|
||||
return None, None, None
|
||||
@@ -1216,7 +1216,6 @@ class BoundingBoxDecorator:
|
||||
|
||||
@staticmethod
|
||||
def find_closest_trihedron(corners, edges, region, rv3d):
|
||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||
|
||||
min_y = float("inf")
|
||||
best_origin = None
|
||||
@@ -1259,8 +1258,7 @@ class BoundingBoxDecorator:
|
||||
self.draw_batch("TRIS", verts, color, [(0, 1, 2), (1, 2, 3)])
|
||||
|
||||
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.bind()
|
||||
@@ -1285,11 +1283,6 @@ class BoundingBoxDecorator:
|
||||
self.draw_batch("LINES", [corners[i1], corners[i2]], color)
|
||||
|
||||
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.bind()
|
||||
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
||||
|
||||
@@ -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
|
||||
scene = context.scene
|
||||
|
||||
if self.measure_xyz_dimensions:
|
||||
if self.show_bounding_box:
|
||||
BoundingBoxDecorator.install(context)
|
||||
# Save previous state if not already saved
|
||||
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_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",
|
||||
default=False,
|
||||
update=update_measure_xyz
|
||||
|
||||
@@ -1334,7 +1334,7 @@ class BIM_PT_decorators_overlay(Panel):
|
||||
row = col.row(align=True)
|
||||
row.prop(model_props, "show_slab_direction", text="Slab Direction")
|
||||
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.prop(model_props, "show_cut_decorator", text="Cut Decorator")
|
||||
row.prop(model_props, "show_cut_decorator_fill", text="Fill Cut Decorator")
|
||||
|
||||
Reference in New Issue
Block a user