From 8813ed66e063d46590ab50e4e9f05da59e35b0fe Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 15 Aug 2023 18:06:02 +1000 Subject: [PATCH] See #3582. Fix bug where switching representations didn't handle curves in a body / model_view. This means that if you created a curve body, you couldn't switch to it, or if you deleted everything, you ended up with an empty object. If you then tried to switch to that, it would "sync" the empty object and leave you with an empty cartesian point list. E.g: 1. Create cube and assign IFC element. 2. Remove all faces only (leaving edges and verts). Save changes. 3. Switch to representation (bug!) 4. Delete everything (no verts, edges, or faces). Attempt to save. 5. "Revert" switch will fail, leading to empty mesh. 6. Manually try to switch. Empty mesh will sync, creating an empty point list. --- src/blenderbim/blenderbim/tool/geometry.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 10f04a7f08..47854d0668 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -434,10 +434,17 @@ class Geometry(blenderbim.core.tool.Geometry): context = representation.ContextOfItems if context.ContextIdentifier == "Body" and context.TargetView == "MODEL_VIEW": - if element.is_a("IfcTypeProduct") or not apply_openings: - shape = ifcopenshell.geom.create_shape(settings, representation) - else: - shape = ifcopenshell.geom.create_shape(settings, element) + try: + if element.is_a("IfcTypeProduct") or not apply_openings: + shape = ifcopenshell.geom.create_shape(settings, representation) + else: + shape = ifcopenshell.geom.create_shape(settings, element) + except: + settings.set(settings.INCLUDE_CURVES, True) + if element.is_a("IfcTypeProduct") or not apply_openings: + shape = ifcopenshell.geom.create_shape(settings, representation) + else: + shape = ifcopenshell.geom.create_shape(settings, element) else: settings.set(settings.INCLUDE_CURVES, True) shape = ifcopenshell.geom.create_shape(settings, representation)