From e43ee28e381bbd097e09686d05714caa1c2eb7a3 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sun, 17 Jan 2021 23:19:12 +0100 Subject: [PATCH] FEM: utils, fix clipping FemMesh without Shape --- src/Mod/Fem/femtools/femutils.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Mod/Fem/femtools/femutils.py b/src/Mod/Fem/femtools/femutils.py index 5bc14b27e6..d46c144223 100644 --- a/src/Mod/Fem/femtools/femutils.py +++ b/src/Mod/Fem/femtools/femutils.py @@ -269,16 +269,26 @@ def getBoundBoxOfAllDocumentShapes(doc): no objects at all return ``None``. """ overalboundbox = None + # netgen mesh obj has an attribute Shape which is an Document obj, which has no BB + # a FemMesh without a Shape could be clipped too + # https://forum.freecadweb.org/viewtopic.php?f=18&t=52920 for o in doc.Objects: - # netgen mesh obj has an attribute Shape which is an Document obj, which has no BB + + bb = None if hasattr(o, "Shape") and hasattr(o.Shape, "BoundBox"): try: bb = o.Shape.BoundBox except Exception: - bb = None - if bb.isValid(): - if not overalboundbox: - overalboundbox = bb + pass + elif hasattr(o, "FemMesh") and hasattr(o.FemMesh, "BoundBox"): + try: + bb = o.FemMesh.BoundBox + except Exception: + pass + if bb.isValid(): + if not overalboundbox: + overalboundbox = bb + else: overalboundbox.add(bb) return overalboundbox