Spatial manager elevation in projects units and some bug fixed

1) Elevation prop now is taking into account project units (previously it was hardcoded to meters)
2) Fixed a bug that occured when you started changing spatial element name/elevation right after you loaded spatial manager.

https://i.imgur.com/1keMGus.png
This commit is contained in:
Andrej730
2023-07-22 11:03:22 +05:00
parent 4a7b8f1104
commit 4c18a89ee6
2 changed files with 6 additions and 2 deletions
@@ -32,6 +32,7 @@ from bpy.props import (
)
import blenderbim.tool as tool
import blenderbim.core.geometry
import ifcopenshell
def update_elevation(self, context):
@@ -43,9 +44,10 @@ def update_elevation(self, context):
def update_active_container_index(self, context):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
self.active_container_id = self.containers[self.active_container_index].ifc_definition_id
self.container_name = self.containers[self.active_container_index].name
self.elevation = self.containers[self.active_container_index].elevation
self.elevation = self.containers[self.active_container_index].elevation * si_conversion
def updateContainerName(self, context):
@@ -90,5 +92,5 @@ class BIMSpatialManagerProperties(PropertyGroup):
active_container_index: IntProperty(name="Active Container Index", update=update_active_container_index)
active_container_id: IntProperty(name="Active Container Id")
container_name: StringProperty(name="Container Name")
elevation: FloatProperty(name="Elevation", update=update_elevation)
elevation: FloatProperty(name="Elevation", update=update_elevation, subtype="DISTANCE")
is_container_update_enabled: BoolProperty(name="Is Container Update Enabled", default=True) # TODO:review
@@ -207,6 +207,8 @@ class Spatial(blenderbim.core.tool.Spatial):
if object.is_a("IfcSpatialElement") or object.is_a("IfcSpatialStructureElement"):
cls.create_new_storey_li(object, 0)
cls.props.is_container_update_enabled = True
# triggers spatial manager props setup
cls.props.active_container_index = 0
@classmethod
def create_new_storey_li(cls, element, level_index):