Bonsai to display units for force measure props

Example - https://i.imgur.com/EhcyIxp.png
This commit is contained in:
Andrej730
2025-01-23 16:40:16 +05:00
parent 4717dffcdc
commit 4ee8176654
2 changed files with 7 additions and 2 deletions
+5 -2
View File
@@ -92,7 +92,7 @@ def draw_attribute(
layout.prop(
attribute,
value_name,
text=attribute.name,
text=attribute.display_name,
)
if attribute.is_uri:
@@ -178,8 +178,11 @@ def import_attribute(
elif data_type == "integer":
new.int_value = 0 if new.is_null else int(data[attribute.name()])
elif data_type == "float":
if attribute.type_of_attribute()._is("IfcLengthMeasure"):
attribute_type = attribute.type_of_attribute()
if attribute_type._is("IfcLengthMeasure"):
new.special_type = "LENGTH"
elif attribute_type._is("IfcForceMeasure"):
new.special_type = "FORCE"
new.float_value = 0.0 if new.is_null else float(data[attribute.name()])
elif data_type == "enum":
enum_items = ifcopenshell.util.attribute.get_enum_items(attribute)
+2
View File
@@ -275,6 +275,7 @@ def get_display_name(self: "Attribute") -> str:
AttributeDataType = Literal["string", "integer", "float", "boolean", "enum", "file"]
AttributeSpecialType = Literal["", "DATE", "DATETIME", "LENGTH", "AREA", "VOLUME", "FORCE"]
class Attribute(PropertyGroup):
@@ -327,6 +328,7 @@ class Attribute(PropertyGroup):
description: str
ifc_class: str
data_type: AttributeDataType
special_type: AttributeSpecialType
def get_value(self) -> Union[str, float, int, bool, None]:
if self.is_optional and self.is_null: