From 2446e52aa85ff6fc65f4f423a1d823bec3cca084 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 27 Sep 2024 09:57:45 +0200 Subject: [PATCH] BIM: Workaround for objects needing recompute --- src/Mod/BIM/nativeifc/ifc_tools.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index c8ec87847c..c17caf2901 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -48,6 +48,7 @@ from nativeifc import ifc_status from nativeifc import ifc_export from draftviewproviders import view_layer +from PySide import QtCore SCALE = 1000.0 # IfcOpenShell works in meters, FreeCAD works in mm SHORT = False # If True, only Step ID attribute is created @@ -334,6 +335,8 @@ def create_children( for child in children: result.extend(create_child(obj, child)) assign_groups(children) + # TEST: mark new objects to recompute + QtCore.QTimer.singleShot(0, lambda: recompute([get_object(c) for c in children])) return result @@ -1419,6 +1422,9 @@ def load_orphans(obj): for o in rest: project.Proxy.addObject(project, o) + # TEST: Try recomputing + QtCore.QTimer.singleShot(0, lambda: recompute(objs)) + def remove_tree(objs): """Removes all given objects and their children, if not used by others""" @@ -1442,3 +1448,13 @@ def remove_tree(objs): doc.removeObject(n) +def recompute(children): + """Temporary function to recompute objects. Some objects don't get their + shape correctly at creation""" + import time + stime = time.time() + for c in children: + c.touch() + FreeCAD.ActiveDocument.recompute() + endtime = "%02d:%02d" % (divmod(round(time.time() - stime, 1), 60)) + print("DEBUG: Extra recomputing of",len(children),"objects took",endtime)