Merge pull request #4833 from carlopav/draft-fix-autogroup

Draft: fix Autogroup to fix Draft_OrthoArray crash when using active Std_Part.
This commit is contained in:
Yorik van Havre
2021-06-09 12:44:42 +02:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ class SketcherSketchObjectGuiTools(GuiTools):
0 : startpoint
1 : endpoint
"""
import Sketcher
if node_idx == 0:
obj.movePoint(0, 1, v)
elif node_idx == 1:

View File

@@ -128,13 +128,20 @@ def autogroup(obj):
if Gui.ActiveDocument.ActiveView.getActiveObject("Arch"):
# add object to active Arch Container
Gui.ActiveDocument.ActiveView.getActiveObject("Arch").addObject(obj)
active_arch_obj = Gui.ActiveDocument.ActiveView.getActiveObject("Arch")
if obj in active_arch_obj.InListRecursive:
# do not autogroup if obj points to active_arch_obj to prevent cyclic references
return
active_arch_obj.addObject(obj)
elif Gui.ActiveDocument.ActiveView.getActiveObject("part", False) is not None:
# add object to active part and change it's placement accordingly
# so object does not jump to different position, works with App::Link
# if not scaled. Modified accordingly to realthunder suggestions
p, parent, sub = Gui.ActiveDocument.ActiveView.getActiveObject("part", False)
active_part, parent, sub = Gui.ActiveDocument.ActiveView.getActiveObject("part", False)
if obj in active_part.InListRecursive:
# do not autogroup if obj points to active_part to prevent cyclic references
return
matrix = parent.getSubObject(sub, retType=4)
if matrix.hasScale() == 1:
err = translate("Draft",
@@ -161,7 +168,8 @@ def autogroup(obj):
elif hasattr(obj,"Placement"):
# every object that have a placement is processed here
obj.Placement = App.Placement(inverse_placement.multiply(obj.Placement))
p.addObject(obj)
active_part.addObject(obj)
def dim_symbol(symbol=None, invert=False):