diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index 71be419015..786944334a 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -286,7 +286,6 @@ class IfcImporter: if self.non_body_contexts: self.settings_2d.set_context_ids(self.non_body_contexts) - def process_element_filter(self): if self.ifc_import_settings.has_filter: self.elements = set(self.ifc_import_settings.elements) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/data.py b/src/blenderbim/blenderbim/bim/module/geometry/data.py new file mode 100644 index 0000000000..6ff788953a --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/geometry/data.py @@ -0,0 +1,61 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import bpy +import blenderbim.tool as tool +import ifcopenshell.util.placement + + +def refresh(): + DerivedPlacementsData.is_loaded = False + + +class DerivedPlacementsData: + data = {} + is_loaded = False + + @classmethod + def load(cls): + cls.data = { + "is_storey": cls.is_storey(), + "storey_height": cls.get_storey_height(), + } + cls.is_loaded = True + + @classmethod + def is_storey(cls): + element = tool.Ifc.get_entity(bpy.context.active_object) + if element: + return element.is_a("IfcBuildingStorey") + + @classmethod + def get_storey_height(cls): + if not cls.is_storey(): + return + element = tool.Ifc.get_entity(bpy.context.active_object) + storeys = [ + (s, ifcopenshell.util.placement.get_local_placement(s.ObjectPlacement)[2][3]) + for s in tool.Ifc.get().by_type("IfcBuildingStorey") + ] + storeys = sorted(storeys, key=lambda s: s[1]) + for i, storey in enumerate(storeys): + if storey[0] != element: + continue + if i >= len(storeys): + return "N/A" + return "{0:.3f}".format(round(storeys[i + 1][1] - storey[1], 3)) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/ui.py b/src/blenderbim/blenderbim/bim/module/geometry/ui.py index cb8daf9ecf..6e9ab862e2 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/ui.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/ui.py @@ -20,6 +20,7 @@ import bpy from bpy.types import Panel from ifcopenshell.api.geometry.data import Data from blenderbim.bim.ifc import IfcStore +from blenderbim.bim.module.geometry.data import DerivedPlacementsData class BIM_PT_representations(Panel): @@ -153,6 +154,9 @@ class BIM_PT_derived_placements(Panel): bl_parent_id = "OBJECT_PT_transform" def draw(self, context): + if not DerivedPlacementsData.is_loaded: + DerivedPlacementsData.load() + z = context.active_object.matrix_world.translation.z z_values = [co[2] for co in context.active_object.bound_box] row = self.layout.row(align=True) @@ -172,6 +176,11 @@ class BIM_PT_derived_placements(Panel): row.label(text="Max Local Z") row.label(text="{0:.3f}".format(max(z_values) + z - collection_z)) + if DerivedPlacementsData.data["is_storey"]: + row = self.layout.row(align=True) + row.label(text="Storey Height") + row.label(text=DerivedPlacementsData.data["storey_height"]) + class BIM_PT_workarounds(Panel): bl_label = "IFC Vendor Workarounds" diff --git a/src/blenderbim/blenderbim/bim/module/project/__init__.py b/src/blenderbim/blenderbim/bim/module/project/__init__.py index 45c5f3a0f8..b21d486c2f 100644 --- a/src/blenderbim/blenderbim/bim/module/project/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/project/__init__.py @@ -53,6 +53,7 @@ classes = ( ui.BIM_UL_links, ) + def menu_func_export(self, context): self.layout.operator(operator.ExportIFC.bl_idname, text="Industry Foundation Classes (.ifc/.ifczip/.ifcjson)")