diff --git a/src/bonsai/bonsai/bim/helper.py b/src/bonsai/bonsai/bim/helper.py index 788e398cde..f96839fe01 100644 --- a/src/bonsai/bonsai/bim/helper.py +++ b/src/bonsai/bonsai/bim/helper.py @@ -153,6 +153,7 @@ def import_attribute( new.data_type = data_type if isinstance(data_type, str) else "" new.ifc_class = data["type"] is_handled_by_callback = callback(attribute.name(), new, data) if callback else None + data_type = new.data_type # Allow callback to override data type. if is_handled_by_callback: pass # Our job is done diff --git a/src/bonsai/bonsai/tool/context.py b/src/bonsai/bonsai/tool/context.py index ec38f2a1e4..62c0a4111a 100644 --- a/src/bonsai/bonsai/tool/context.py +++ b/src/bonsai/bonsai/tool/context.py @@ -43,6 +43,10 @@ class Context(bonsai.core.tool.Context): elif name == "CoordinateSpaceDimension": props.context_attributes.remove(props.context_attributes.find("CoordinateSpaceDimension")) return True + else: # IfcGeometricRepresentationContext + # Import precision as a string because Blender has problem displaying 1e-7 and smaller numbers in UI. + if name == "Precision": + prop.data_type = "string" bonsai.bim.helper.import_attributes(context.is_a(), props.context_attributes, context.get_info(), callback) @@ -56,4 +60,12 @@ class Context(bonsai.core.tool.Context): @classmethod def export_attributes(cls) -> dict[str, Any]: - return bonsai.bim.helper.export_attributes(bpy.context.scene.BIMContextProperties.context_attributes) + def callback(attributes, blender_attribute) -> bool: + if blender_attribute.name == "Precision": + attributes["Precision"] = float(blender_attribute.get_value()) + return True + return False + + return bonsai.bim.helper.export_attributes( + bpy.context.scene.BIMContextProperties.context_attributes, callback=callback + )