[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 <yorik.vanhavre@gmail.com> --------- Co-authored-by: Yorik van Havre <yorik.vanhavre@gmail.com>
This commit is contained in:
@@ -43,6 +43,16 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def proceed(self):
|
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."""
|
"""Proceed with the command if one object was selected."""
|
||||||
# difference from Draft: it sets InPlace to False
|
# difference from Draft: it sets InPlace to False
|
||||||
import DraftVecUtils
|
import DraftVecUtils
|
||||||
@@ -59,6 +69,7 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
|
|||||||
if "Face" in e:
|
if "Face" in e:
|
||||||
faces.append(int(e[4:]) - 1)
|
faces.append(int(e[4:]) - 1)
|
||||||
# print(objs, faces)
|
# print(objs, faces)
|
||||||
|
self.objs_BimShape2DView = objs
|
||||||
commitlist = []
|
commitlist = []
|
||||||
FreeCADGui.addModule("Draft")
|
FreeCADGui.addModule("Draft")
|
||||||
if len(objs) == 1 and faces:
|
if len(objs) == 1 and faces:
|
||||||
@@ -68,8 +79,10 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
|
|||||||
_cmd += DraftVecUtils.toString(vec) + ", "
|
_cmd += DraftVecUtils.toString(vec) + ", "
|
||||||
_cmd += "facenumbers=" + str(faces)
|
_cmd += "facenumbers=" + str(faces)
|
||||||
_cmd += ")"
|
_cmd += ")"
|
||||||
commitlist.append("sv = " + _cmd)
|
#commitlist.append("sv = " + _cmd)
|
||||||
commitlist.append("sv.InPlace = False")
|
#commitlist.append("sv.InPlace = False")
|
||||||
|
commitlist.append("sv0 = " + _cmd)
|
||||||
|
commitlist.append("sv0.InPlace = False")
|
||||||
else:
|
else:
|
||||||
n = 0
|
n = 0
|
||||||
for o in objs:
|
for o in objs:
|
||||||
@@ -82,10 +95,14 @@ class BIM_Shape2DView(gui_shape2dview.Shape2DView):
|
|||||||
commitlist.append("sv" + str(n) + ".InPlace = False")
|
commitlist.append("sv" + str(n) + ".InPlace = False")
|
||||||
n += 1
|
n += 1
|
||||||
if commitlist:
|
if commitlist:
|
||||||
commitlist.append("FreeCAD.ActiveDocument.recompute()")
|
#commitlist.append("FreeCAD.ActiveDocument.recompute()")
|
||||||
self.commit(translate("draft", "Create 2D view"),
|
self.commitlist_BimShape2DView = commitlist
|
||||||
commitlist)
|
else:
|
||||||
self.finish()
|
self.commitlist_BimShape2DView = None
|
||||||
|
|
||||||
|
# self.commit(translate("draft", "Create 2D view"),
|
||||||
|
# commitlist)
|
||||||
|
#self.finish()
|
||||||
|
|
||||||
|
|
||||||
class BIM_Shape2DCut(BIM_Shape2DView):
|
class BIM_Shape2DCut(BIM_Shape2DView):
|
||||||
@@ -98,8 +115,26 @@ class BIM_Shape2DCut(BIM_Shape2DView):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def proceed(self):
|
def proceed(self):
|
||||||
super().proceed()
|
#super().proceed()
|
||||||
FreeCADGui.doCommand("sv.ProjectionMode = \"Cutfaces\"")
|
#'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())
|
FreeCADGui.addCommand("BIM_Shape2DView", BIM_Shape2DView())
|
||||||
|
|||||||
Reference in New Issue
Block a user