mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Bonsai to display units for force measure props
Example - https://i.imgur.com/EhcyIxp.png
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user