From 13e006cf352a317bee9126b31adcedf31e2ec044 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 21 Jun 2014 11:59:33 -0300 Subject: [PATCH] Arch: added an option to section planes to allow non-solids to be cut too --- src/Mod/Arch/ArchSectionPlane.py | 10 +++++++++- src/Mod/Draft/Draft.py | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 812f14272..9479c9750 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -100,6 +100,8 @@ class _SectionPlane: obj.addProperty("App::PropertyPlacement","Placement","Base",translate("Arch","The placement of this object")) obj.addProperty("Part::PropertyPartShape","Shape","Base","") obj.addProperty("App::PropertyLinkList","Objects","Arch",translate("Arch","The objects that must be considered by this section plane. Empty means all document")) + obj.addProperty("App::PropertyBool","OnlySolids","Arch",translate("Arch","If false, non-solids will be cut too, with possible wrong results.")) + obj.OnlySolids = True self.Type = "SectionPlane" def execute(self,obj): @@ -327,7 +329,13 @@ class _ArchDrawingView: pass #FreeCAD.Console.PrintWarning(translate("Arch","Skipping empty object: ")+o.Name) elif o.Shape.isValid(): - shapes.extend(o.Shape.Solids) + if hasattr(obj.Source,"OnlySolids"): + if obj.Source.OnlySolids: + shapes.extend(o.Shape.Solids) + else: + shapes.append(o.Shape) + else: + shapes.extend(o.Shape.Solids) else: FreeCAD.Console.PrintWarning(translate("Arch","Skipping invalid object: ")+o.Name) cutface,cutvolume,invcutvolume = ArchCommands.getCutVolume(obj.Source.Shape.copy(),shapes) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index b70fadf91..2fc152d0f 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -4289,21 +4289,34 @@ class _Shape2DView(_DraftObject): if obj.Base: if getType(obj.Base) == "SectionPlane": if obj.Base.Objects: + onlysolids = True + if hasattr(obj.Base,"OnlySolids"): + onlysolids = obj.Base.OnlySolids import Arch, Part, Drawing objs = getGroupContents(obj.Base.Objects,walls=True) objs = removeHidden(objs) shapes = [] for o in objs: if o.isDerivedFrom("Part::Feature"): - shapes.extend(o.Shape.Solids) + if onlysolids: + shapes.extend(o.Shape.Solids) + else: + shapes.append(o.Shape.copy()) cutp,cutv,iv =Arch.getCutVolume(obj.Base.Shape,shapes) cuts = [] if obj.ProjectionMode == "Solid": for sh in shapes: if sh.Volume < 0: sh.reverse() + #if cutv.BoundBox.isIntersection(sh.BoundBox): + # c = sh.cut(cutv) + #else: + # c = sh.copy() c = sh.cut(cutv) - cuts.extend(c.Solids) + if onlysolids: + cuts.extend(c.Solids) + else: + cuts.append(c) comp = Part.makeCompound(cuts) opl = FreeCAD.Placement(obj.Base.Placement) proj = opl.Rotation.multVec(FreeCAD.Vector(0,0,1))