From fcbbe9535fd92cbc3fd855e595eb5e02195c8ddd Mon Sep 17 00:00:00 2001 From: paul <40677073+paullee0@users.noreply.github.com> Date: Fri, 28 Feb 2025 17:08:56 +0800 Subject: [PATCH] [BimShape2DView] Bug-Fix : Shape2DCut Not Working (#19316) * [BimShape2DView] Bug-Fix : Shape2DCut Not Working GitHub Issue - https://github.com/FreeCAD/FreeCAD/issues/18947 * Update src/Mod/BIM/bimcommands/BimShape2DView.py Co-authored-by: Yorik van Havre --------- Co-authored-by: Yorik van Havre --- src/Mod/BIM/bimcommands/BimShape2DView.py | 51 +++++++++++++++++++---- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimShape2DView.py b/src/Mod/BIM/bimcommands/BimShape2DView.py index fecbee7e8c..3d69e95c34 100644 --- a/src/Mod/BIM/bimcommands/BimShape2DView.py +++ b/src/Mod/BIM/bimcommands/BimShape2DView.py @@ -43,6 +43,16 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView): return d def proceed(self): + """Proceed with the command if one object was selected.""" + self.proceed_BimShape2DView() # Common + if self.commitlist_BimShape2DView: + commitlist = self.commitlist_BimShape2DView + commitlist.append("FreeCAD.ActiveDocument.recompute()") + self.commit(translate("draft", "Create 2D view"), + self.commitlist_BimShape2DView) + self.finish() + + def proceed_BimShape2DView(self): # Common """Proceed with the command if one object was selected.""" # difference from Draft: it sets InPlace to False import DraftVecUtils @@ -59,6 +69,7 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView): if "Face" in e: faces.append(int(e[4:]) - 1) # print(objs, faces) + self.objs_BimShape2DView = objs commitlist = [] FreeCADGui.addModule("Draft") if len(objs) == 1 and faces: @@ -68,8 +79,10 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView): _cmd += DraftVecUtils.toString(vec) + ", " _cmd += "facenumbers=" + str(faces) _cmd += ")" - commitlist.append("sv = " + _cmd) - commitlist.append("sv.InPlace = False") + #commitlist.append("sv = " + _cmd) + #commitlist.append("sv.InPlace = False") + commitlist.append("sv0 = " + _cmd) + commitlist.append("sv0.InPlace = False") else: n = 0 for o in objs: @@ -82,10 +95,14 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView): commitlist.append("sv" + str(n) + ".InPlace = False") n += 1 if commitlist: - commitlist.append("FreeCAD.ActiveDocument.recompute()") - self.commit(translate("draft", "Create 2D view"), - commitlist) - self.finish() + #commitlist.append("FreeCAD.ActiveDocument.recompute()") + self.commitlist_BimShape2DView = commitlist + else: + self.commitlist_BimShape2DView = None + + # self.commit(translate("draft", "Create 2D view"), + # commitlist) + #self.finish() class BIM_Shape2DCut(BIM_Shape2DView): @@ -98,8 +115,26 @@ class BIM_Shape2DCut(BIM_Shape2DView): return d def proceed(self): - super().proceed() - FreeCADGui.doCommand("sv.ProjectionMode = \"Cutfaces\"") + #super().proceed() + #'sv' is not passed from BIM_Shape2DView() to BIM_Shape2DCut() + #FreeCADGui.doCommand("sv.ProjectionMode = \"Cutfaces\"") + + """Proceed with the command if one object was selected.""" + self.proceed_BimShape2DView() # Common + if self.commitlist_BimShape2DView: + commitlist = self.commitlist_BimShape2DView + + # BIM_Shape2DCut specific + #commitlist.append("sv.ProjectionMode = \"Cutfaces\"") + objs = self.objs_BimShape2DView + n = 0 + for o in objs: + commitlist.append("sv" + str(n) + ".ProjectionMode = \"Cutfaces\"") + n += 1 + commitlist.append("FreeCAD.ActiveDocument.recompute()") + self.commit(translate("draft", "Create 2D Cut"), + commitlist) + self.finish() FreeCADGui.addCommand("BIM_Shape2DView", BIM_Shape2DView())