mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Contexts UI - import Precision as string due problems with Blender UI
Btw this is where you can edit model geometry precision - https://i.imgur.com/CLln0oK.png Related Blender issue - https://projects.blender.org/blender/blender/issues/128238
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user