From b701bfd1e1d665b0744c07c8618bd75682f3914b Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sun, 3 Jun 2012 23:44:20 -0300 Subject: [PATCH] Arch: Several bugfixes in arch objects --- src/Mod/Arch/ArchComponent.py | 4 +- src/Mod/Arch/ArchStructure.py | 20 +++++----- src/Mod/Arch/ArchWall.py | 33 ++++++++------- src/Mod/Arch/ArchWindow.py | 75 ++++++++++++++++++----------------- 4 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index c9fa5a347..13ad37204 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -257,9 +257,9 @@ class Component: obj.addProperty("App::PropertyLink","Base","Base", "The base object this component is built upon") obj.addProperty("App::PropertyLinkList","Additions","Base", - "Other shapes that are appended to this wall") + "Other shapes that are appended to this object") obj.addProperty("App::PropertyLinkList","Subtractions","Base", - "Other shapes that are subtracted from this wall") + "Other shapes that are subtracted from this object") obj.Proxy = self self.Type = "Component" self.Subvolume = None diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 7bf73cc1e..d257c4d92 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -163,17 +163,13 @@ class _Structure(ArchComponent.Component): base = Part.Face(base) base = base.extrude(normal) for app in obj.Additions: - base = base.oldFuse(app.Shape) - app.ViewObject.hide() # to be removed + if hasattr(app,"Shape"): + if not app.Shape.isNull(): + base = base.fuse(app.Shape) + app.ViewObject.hide() # to be removed for hole in obj.Subtractions: - cut = False - if hasattr(hole,"Proxy"): - if hasattr(hole.Proxy,"Subvolume"): - if hole.Proxy.Subvolume: - base = base.cut(hole.Proxy.Subvolume) - cut = True - if not cut: - if hasattr(obj,"Shape"): + if hasattr(hole,"Shape"): + if not hole.Shape.isNull(): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed if base: @@ -186,7 +182,9 @@ class _Structure(ArchComponent.Component): fsh.append(sh) obj.Shape = Part.makeCompound(fsh) else: - obj.Shape = base + if not base.isNull(): + base = base.removeSplitter() + obj.Shape = base if not DraftGeomUtils.isNull(pl): obj.Placement = pl class _ViewProviderStructure(ArchComponent.ViewProviderComponent): diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 4b9db7ee0..0bfa8f6e4 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -272,20 +272,23 @@ class _Wall(ArchComponent.Component): "returns a subvolume from a base object" import Part max_length = 0 + f = None for w in base.Shape.Wires: if w.BoundBox.DiagonalLength > max_length: max_length = w.BoundBox.DiagonalLength f = w - f = Part.Face(f) - n = f.normalAt(0,0) - v1 = DraftVecUtils.scaleTo(n,width) - f.translate(v1) - v2 = DraftVecUtils.neg(v1) - v2 = DraftVecUtils.scale(v1,-2) - f = f.extrude(v2) - if delta: - f.translate(delta) - return f + if f: + f = Part.Face(f) + n = f.normalAt(0,0) + v1 = DraftVecUtils.scaleTo(n,width) + f.translate(v1) + v2 = DraftVecUtils.neg(v1) + v2 = DraftVecUtils.scale(v1,-2) + f = f.extrude(v2) + if delta: + f.translate(delta) + return f + return None def createGeometry(self,obj): "builds the wall shape" @@ -368,27 +371,29 @@ class _Wall(ArchComponent.Component): else: temp = sh base = temp - base = base.removeSplitter() for app in obj.Additions: - base = base.oldFuse(app.Shape) + base = base.fuse(app.Shape) app.ViewObject.hide() #to be removed for hole in obj.Subtractions: if Draft.getType(hole) == "Window": # window if hole.Base and obj.Width: f = self.getSubVolume(hole.Base,width) - base = base.cut(f) + if f: + base = base.cut(f) elif Draft.isClone(hole,"Window"): if hole.Objects[0].Base and width: f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement.Base) - base = base.cut(f) + if f: + base = base.cut(f) elif hasattr(hole,"Shape"): if not hole.Shape.isNull(): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed if base: + base.removeSplitter() obj.Shape = base if not DraftGeomUtils.isNull(pl): obj.Placement = pl diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index de7df1b6e..2c20b03ca 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -117,6 +117,7 @@ class _Window(ArchComponent.Component): obj.addProperty("App::PropertyStringList","WindowParts","Base", str(translate("Arch","the components of this window"))) self.Type = "Window" + obj.Proxy = self def execute(self,obj): self.createGeometry(obj) @@ -130,43 +131,45 @@ class _Window(ArchComponent.Component): pl = obj.Placement if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): - if obj.WindowParts and (len(obj.WindowParts)%5 == 0): - shapes = [] - for i in range(len(obj.WindowParts)/5): - wires = [] - wstr = obj.WindowParts[(i*5)+2].split(',') - for s in wstr: - j = int(s[4:]) - if obj.Base.Shape.Wires: - if len(obj.Base.Shape.Wires) >= j: - wires.append(obj.Base.Shape.Wires[j]) - if wires: - max_length = 0 - for w in wires: - if w.BoundBox.DiagonalLength > max_length: - max_length = w.BoundBox.DiagonalLength - ext = w - wires.remove(ext) - shape = Part.Face(ext) - norm = shape.normalAt(0,0) - thk = float(obj.WindowParts[(i*5)+3]) - if thk: - exv = DraftVecUtils.scaleTo(norm,thk) - shape = shape.extrude(exv) + if hasattr(obj,"WindowParts"): + if obj.WindowParts and (len(obj.WindowParts)%5 == 0): + shapes = [] + for i in range(len(obj.WindowParts)/5): + wires = [] + wstr = obj.WindowParts[(i*5)+2].split(',') + for s in wstr: + j = int(s[4:]) + if obj.Base.Shape.Wires: + if len(obj.Base.Shape.Wires) >= j: + wires.append(obj.Base.Shape.Wires[j]) + if wires: + max_length = 0 for w in wires: - f = Part.Face(w) - f = f.extrude(exv) - shape = shape.cut(f) - if obj.WindowParts[(i*5)+4]: - zof = float(obj.WindowParts[(i*5)+4]) - if zof: - zov = DraftVecUtils.scaleTo(norm,zof) - shape.translate(zov) - print shape - shapes.append(shape) - obj.Shape = Part.makeCompound(shapes) - if not DraftGeomUtils.isNull(pl): - obj.Placement = pl + if w.BoundBox.DiagonalLength > max_length: + max_length = w.BoundBox.DiagonalLength + ext = w + wires.remove(ext) + shape = Part.Face(ext) + norm = shape.normalAt(0,0) + thk = float(obj.WindowParts[(i*5)+3]) + if thk: + exv = DraftVecUtils.scaleTo(norm,thk) + shape = shape.extrude(exv) + for w in wires: + f = Part.Face(w) + f = f.extrude(exv) + shape = shape.cut(f) + if obj.WindowParts[(i*5)+4]: + zof = float(obj.WindowParts[(i*5)+4]) + if zof: + zov = DraftVecUtils.scaleTo(norm,zof) + shape.translate(zov) + print shape + shapes.append(shape) + if shapes: + obj.Shape = Part.makeCompound(shapes) + if not DraftGeomUtils.isNull(pl): + obj.Placement = pl class _ViewProviderWindow(ArchComponent.ViewProviderComponent): "A View Provider for the Window object"