From a08d5a4c1e0df0a64e60c4ace061af3401209cae Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Fri, 4 Oct 2024 10:46:55 +0200 Subject: [PATCH] BIM: Compatibility fix for walls based on wire or face with -Z normal In V1.0 the handling of wall normals has changed. As a result existing walls with their Normal set to [0, 0, 0], based on wires or faces with a shape normal pointing towards -Z, would be extruded in that direction instead of towards +Z as before. To avoid this their Normal property is changed to [0, 0, 1]. --- src/Mod/BIM/ArchWall.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Mod/BIM/ArchWall.py b/src/Mod/BIM/ArchWall.py index 7833035099..334bd877a6 100644 --- a/src/Mod/BIM/ArchWall.py +++ b/src/Mod/BIM/ArchWall.py @@ -216,9 +216,32 @@ class _Wall(ArchComponent.Component): def onDocumentRestored(self,obj): """Method run when the document is restored. Re-adds the Arch component, and Arch wall properties.""" + import DraftGeomUtils + from draftutils.messages import _wrn + ArchComponent.Component.onDocumentRestored(self,obj) self.setProperties(obj) + # In V1.0 the handling of wall normals has changed. As a result existing + # walls with their Normal set to [0, 0, 0], based on wires or faces with + # a shape normal pointing towards -Z, would be extruded in that direction + # instead of towards +Z as before. To avoid this their Normal property is + # changed to [0, 0, 1]. + if FreeCAD.ActiveDocument.getProgramVersion() < "0.22" \ + and obj.Normal == Vector(0, 0, 0) \ + and hasattr(obj.Base, "Shape") \ + and not obj.Base.Shape.Solids \ + and obj.Face == 0 \ + and not obj.Base.isDerivedFrom("Sketcher::SketchObject") \ + and DraftGeomUtils.get_shape_normal(obj.Base.Shape) != Vector(0, 0, 1): + obj.Normal = Vector(0, 0, 1) + _wrn( + "v1.0, " + + obj.Label + + ", " + + translate("Arch", "changed 'Normal' to [0, 0, 1] to preserve extrusion direction") + ) + if hasattr(obj,"ArchSketchData") and obj.ArchSketchData and Draft.getType(obj.Base) == "ArchSketch": if hasattr(obj,"Width"): obj.setEditorMode("Width", ["ReadOnly"])