From 93ec1cbfc2d6e7119fc1e3a001eef1718870ae3c Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sat, 7 Dec 2024 10:58:58 -0600 Subject: [PATCH] closes #5086: a preference to assign which classes display as wireframe upon opening the IFC file --- src/bonsai/bonsai/bim/import_ifc.py | 6 ++++++ src/bonsai/bonsai/bim/module/drawing/prop.py | 5 +++++ src/bonsai/bonsai/bim/ui.py | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index e3455a9f94..c8d3970b87 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -203,6 +203,8 @@ class IfcImporter: self.progress = 0 self.material_creator = MaterialCreator(ifc_import_settings, self) + classes_to_wireframe_str = bpy.context.scene.DocProperties.classes_to_wireframe + self.classes_to_wireframe_list = [word.strip() for word in classes_to_wireframe_str.split(",")] def profile_code(self, message: str) -> None: if not self.time: @@ -815,6 +817,10 @@ class IfcImporter: obj = bpy.data.objects.new(tool.Loader.get_name(element), mesh) self.link_element(element, obj) + for ifcclass in self.classes_to_wireframe_list: + if element.is_a(ifcclass): + obj.display_type = 'WIRE' + if shape: # We use numpy here because Blender mathutils.Matrix is not accurate enough mat = np.array(shape.transformation.matrix).reshape((4, 4), order="F") diff --git a/src/bonsai/bonsai/bim/module/drawing/prop.py b/src/bonsai/bonsai/bim/module/drawing/prop.py index 85410f8354..d561472066 100644 --- a/src/bonsai/bonsai/bim/module/drawing/prop.py +++ b/src/bonsai/bonsai/bim/module/drawing/prop.py @@ -402,6 +402,11 @@ class DocProperties(PropertyGroup): magic_font_scale: bpy.props.FloatProperty(default=0.004118616, name="Font Scale Factor") imperial_precision: StringProperty(default="1/32", name="Imperial Precision") tolerance: bpy.props.FloatProperty(default=0.00001, name="A tolerance used when selecting objects") + classes_to_wireframe: StringProperty( + default="IfcVirtualelement", + name="Classes to Wireframe", + description = "Upon import, these classes will display as wireframe.\nEx: IfcVirtualelement, IfcSpace" + ) class BIMCameraProperties(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index 0e7ce9f1b1..16917077ca 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -383,6 +383,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences): row.prop(context.scene.DocProperties, "imperial_precision") row = self.layout.row() row.prop(context.scene.DocProperties, "tolerance") + row = self.layout.row() + row.prop(context.scene.DocProperties, "classes_to_wireframe") # Scene panel groups