mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Units formatting for Spatial Manager
Noticed in Sigma Dimensions video that we have some floating point garbage displayed in the Spatial Manager UI and I've added some simple formatting. Now - https://i.imgur.com/eM1rDDu.png Before - https://i.imgur.com/ySln5uU.png
This commit is contained in:
@@ -44,10 +44,9 @@ 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 * si_conversion
|
||||
self.elevation = self.containers[self.active_container_index].elevation
|
||||
|
||||
|
||||
def updateContainerName(self, context):
|
||||
@@ -78,7 +77,7 @@ class BIMObjectSpatialProperties(PropertyGroup):
|
||||
|
||||
class BIMContainer(PropertyGroup):
|
||||
name: StringProperty(name="Name", update=updateContainerName)
|
||||
elevation: FloatProperty(name="Elevation")
|
||||
elevation: FloatProperty(name="Elevation", subtype="DISTANCE")
|
||||
level_index: IntProperty(name="Level Index")
|
||||
has_children: BoolProperty(name="Has Children")
|
||||
is_expanded: BoolProperty(name="Is Expanded")
|
||||
|
||||
@@ -147,7 +147,7 @@ class BIM_UL_containers_manager(UIList):
|
||||
split1 = row.split(factor=0.7)
|
||||
split1.prop(item, "name", emboss=False, text="")
|
||||
split2 = row.split(factor=1)
|
||||
split2.label(text=str(item.elevation), icon="BLANK1")
|
||||
split2.label(icon="BLANK1", text=tool.Unit.blender_format_unit(item.elevation))
|
||||
|
||||
def draw_hierarchy(self, row, item):
|
||||
for i in range(0, item.level_index):
|
||||
|
||||
@@ -212,12 +212,13 @@ class Spatial(blenderbim.core.tool.Spatial):
|
||||
|
||||
@classmethod
|
||||
def create_new_storey_li(cls, element, level_index):
|
||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
new = cls.props.containers.add()
|
||||
new.name = element.Name or "Unnamed"
|
||||
new.long_name = element.LongName or ""
|
||||
new.has_decomposition = bool(element.IsDecomposedBy)
|
||||
new.ifc_definition_id = element.id()
|
||||
new.elevation = ifcopenshell.util.placement.get_storey_elevation(element)
|
||||
new.elevation = ifcopenshell.util.placement.get_storey_elevation(element) * si_conversion
|
||||
|
||||
new.is_expanded = element.id() not in cls.contracted_containers
|
||||
new.level_index = level_index
|
||||
|
||||
@@ -163,3 +163,13 @@ class Unit(blenderbim.core.tool.Unit):
|
||||
unit = cls.get_project_currency_unit()
|
||||
if unit:
|
||||
return unit.Currency
|
||||
|
||||
@classmethod
|
||||
def blender_format_unit(cls, value):
|
||||
return bpy.utils.units.to_string(
|
||||
bpy.context.scene.unit_settings.system,
|
||||
"LENGTH",
|
||||
value,
|
||||
precision=4,
|
||||
split_unit=bpy.context.scene.unit_settings.system == "IMPERIAL",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user