From 8e8b93aab1467d82c45e33405f29f4d98b14bae5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 8 Apr 2019 18:18:11 -0300 Subject: [PATCH] Draft: Shape2DView can now fuse Arch Walls and Structures --- src/Mod/Draft/Draft.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index f409c6d1c0..4bced1523f 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -5155,6 +5155,7 @@ class _Shape2DView(_DraftObject): obj.addProperty("App::PropertyEnumeration","ProjectionMode","Draft",QT_TRANSLATE_NOOP("App::Property","The way the viewed object must be projected")) obj.addProperty("App::PropertyIntegerList","FaceNumbers","Draft",QT_TRANSLATE_NOOP("App::Property","The indices of the faces to be projected in Individual Faces mode")) obj.addProperty("App::PropertyBool","HiddenLines","Draft",QT_TRANSLATE_NOOP("App::Property","Show hidden lines")) + obj.addProperty("App::PropertyBool","FuseArch","Draft",QT_TRANSLATE_NOOP("App::Property","Fuse wall and structure objects of same type and material")) obj.addProperty("App::PropertyBool","Tessellation","Draft",QT_TRANSLATE_NOOP("App::Property","Tessellate Ellipses and B-splines into line segments")) obj.addProperty("App::PropertyBool","InPlace","Draft",QT_TRANSLATE_NOOP("App::Property","For Cutlines and Cutfaces modes, this leaves the faces at the cut location")) obj.addProperty("App::PropertyFloat","SegmentLength","Draft",QT_TRANSLATE_NOOP("App::Property","Length of line segments if tessellating Ellipses or B-splines into line segments")) @@ -5206,12 +5207,36 @@ class _Shape2DView(_DraftObject): objs = getGroupContents(obj.Base.Objects,walls=True) objs = removeHidden(objs) shapes = [] - for o in objs: - if o.isDerivedFrom("Part::Feature"): - if onlysolids: - shapes.extend(o.Shape.Solids) + if hasattr(obj,"FuseArch") and obj.FuseArch: + shtypes = {} + for o in objs: + if getType(o) in ["Wall","Structure"]: + if onlysolids: + shtypes.setdefault(o.Material.Name if (hasattr(o,"Material") and o.Material) else "None",[]).extend(o.Shape.Solids) + else: + shtypes.setdefault(o.Material.Name if (hasattr(o,"Material") and o.Material) else "None",[]).append(o.Shape.copy()) + elif o.isDerivedFrom("Part::Feature"): + if onlysolids: + shapes.extend(o.Shape.Solids) + else: + shapes.append(o.Shape.copy()) + for k,v in shtypes.items(): + v1 = v.pop() + if v: + v1 = v1.multiFuse(v) + v1 = v1.removeSplitter() + if v1.Solids: + shapes.extend(v1.Solids) else: - shapes.append(o.Shape.copy()) + print("Shape2DView: Fusing Arch objects produced non-solid results") + shapes.append(v1) + else: + for o in objs: + if o.isDerivedFrom("Part::Feature"): + if onlysolids: + shapes.extend(o.Shape.Solids) + else: + shapes.append(o.Shape.copy()) cutp,cutv,iv =Arch.getCutVolume(obj.Base.Shape,shapes) cuts = [] opl = FreeCAD.Placement(obj.Base.Placement)