(self)
| 114 | self.should_create_edges = should_create_edges |
| 115 | |
| 116 | def patch(self) -> None: |
| 117 | import bmesh # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import] |
| 118 | import bonsai.tool as tool |
| 119 | import bpy # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import] |
| 120 | import ifcopenshell.util.schema |
| 121 | import ifcopenshell.util.unit |
| 122 | |
| 123 | props = tool.Project.get_project_props() |
| 124 | props.should_use_native_meshes = True |
| 125 | bpy.ops.bim.load_project(filepath=self.filepath) |
| 126 | |
| 127 | old_history_size = tool.Ifc.get().history_size |
| 128 | old_undo_steps = bpy.context.preferences.edit.undo_steps |
| 129 | tool.Ifc.get().history_size = 0 |
| 130 | bpy.context.preferences.edit.undo_steps = 0 |
| 131 | |
| 132 | self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) |
| 133 | |
| 134 | for obj in bpy.data.objects: |
| 135 | if not tool.Blender.get_ifc_definition_id(obj) or not obj.data: |
| 136 | continue |
| 137 | if not obj.data.polygons: |
| 138 | continue |
| 139 | element = tool.Ifc.get_entity(obj) |
| 140 | element.PredefinedType = "USERDEFINED" |
| 141 | element.ObjectType = "TIN" |
| 142 | element = ifcopenshell.util.schema.reassign_class(tool.Ifc.get(), element, "IfcGeographicElement") |
| 143 | |
| 144 | bm = bmesh.new() |
| 145 | bm.from_mesh(obj.data) |
| 146 | faces_to_delete = [] |
| 147 | if self.is_solid: |
| 148 | for face in bm.faces: |
| 149 | global_normal = obj.matrix_world.to_3x3() @ face.normal |
| 150 | if global_normal.z < 0.5: |
| 151 | faces_to_delete.append(face) |
| 152 | bmesh.ops.delete(bm, geom=faces_to_delete, context="FACES_ONLY") |
| 153 | bmesh.ops.triangulate(bm, faces=bm.faces[:], quad_method="BEAUTY", ngon_method="BEAUTY") |
| 154 | bm.to_mesh(obj.data) |
| 155 | bm.free() |
| 156 | obj.data.update() |
| 157 | |
| 158 | if self.should_create_edges: |
| 159 | self.create_edges(obj) |
| 160 | |
| 161 | self.create_face_sampleable_object(obj) |
| 162 | self.create_edge_sampleable_object(obj) |
| 163 | |
| 164 | tool.Ifc.get().history_size = old_history_size |
| 165 | bpy.context.preferences.edit.undo_steps = old_undo_steps |
| 166 | |
| 167 | self.file = tool.Ifc.get() |
| 168 | |
| 169 | def create_edges(self, obj: bpy.types.Object) -> None: |
| 170 | import bmesh # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import] |
nothing calls this directly
no test coverage detected