mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +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(
|
layout.prop(
|
||||||
attribute,
|
attribute,
|
||||||
value_name,
|
value_name,
|
||||||
text=attribute.name,
|
text=attribute.display_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
if attribute.is_uri:
|
if attribute.is_uri:
|
||||||
@@ -178,8 +178,11 @@ def import_attribute(
|
|||||||
elif data_type == "integer":
|
elif data_type == "integer":
|
||||||
new.int_value = 0 if new.is_null else int(data[attribute.name()])
|
new.int_value = 0 if new.is_null else int(data[attribute.name()])
|
||||||
elif data_type == "float":
|
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"
|
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()])
|
new.float_value = 0.0 if new.is_null else float(data[attribute.name()])
|
||||||
elif data_type == "enum":
|
elif data_type == "enum":
|
||||||
enum_items = ifcopenshell.util.attribute.get_enum_items(attribute)
|
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"]
|
AttributeDataType = Literal["string", "integer", "float", "boolean", "enum", "file"]
|
||||||
|
AttributeSpecialType = Literal["", "DATE", "DATETIME", "LENGTH", "AREA", "VOLUME", "FORCE"]
|
||||||
|
|
||||||
|
|
||||||
class Attribute(PropertyGroup):
|
class Attribute(PropertyGroup):
|
||||||
@@ -327,6 +328,7 @@ class Attribute(PropertyGroup):
|
|||||||
description: str
|
description: str
|
||||||
ifc_class: str
|
ifc_class: str
|
||||||
data_type: AttributeDataType
|
data_type: AttributeDataType
|
||||||
|
special_type: AttributeSpecialType
|
||||||
|
|
||||||
def get_value(self) -> Union[str, float, int, bool, None]:
|
def get_value(self) -> Union[str, float, int, bool, None]:
|
||||||
if self.is_optional and self.is_null:
|
if self.is_optional and self.is_null:
|
||||||
|
|||||||
Reference in New Issue
Block a user