From cd2adf6a28b457d7e969964689a0831abba200bd Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 12 Apr 2012 11:35:24 -0300 Subject: [PATCH] Fixed several bugs when loading Arch objects from files --- src/Mod/Arch/ArchStructure.py | 8 ++--- src/Mod/Arch/ArchWall.py | 68 ++++++++++++++++++++--------------- src/Mod/Arch/ArchWindow.py | 6 ++-- 3 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index daa7b25e9..63d7b668c 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -119,10 +119,10 @@ class _Structure(ArchComponent.Component): length = obj.Length else: length = 1 - if obj.Width: - width = obj.Width - else: - width = 1 + width = 1 + if hasattr(obj,"Width"): + if obj.Width: + width = obj.Width if obj.Height: height = obj.Height else: diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 2ba56f1fa..4ee4c47a2 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -294,22 +294,27 @@ class _Wall(ArchComponent.Component): flat = False if hasattr(obj.ViewObject,"DisplayMode"): flat = (obj.ViewObject.DisplayMode == "Flat 2D") + + width = 1.0 + if hasattr(obj,"Width"): + if obj.Width: + width = obj.Width def getbase(wire): "returns a full shape from a base wire" dvec = fcgeo.vec(wire.Edges[0]).cross(normal) dvec.normalize() if obj.Align == "Left": - dvec = dvec.multiply(obj.Width) + dvec = dvec.multiply(width) w2 = fcgeo.offsetWire(wire,dvec) sh = fcgeo.bind(wire,w2) elif obj.Align == "Right": - dvec = dvec.multiply(obj.Width) + dvec = dvec.multiply(width) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire,dvec) sh = fcgeo.bind(wire,w2) elif obj.Align == "Center": - dvec = dvec.multiply(obj.Width/2) + dvec = dvec.multiply(width/2) w1 = fcgeo.offsetWire(wire,dvec) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire,dvec) @@ -338,32 +343,37 @@ class _Wall(ArchComponent.Component): normal = Vector(obj.Normal) # computing shape + base = None if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): - base = obj.Base.Shape.copy() - if base.Solids: - pass - elif base.Faces: - if height: - norm = normal.multiply(height) - base = base.extrude(norm) - elif base.Wires: - temp = None - for wire in obj.Base.Shape.Wires: - sh = getbase(wire) - if temp: - temp = temp.oldFuse(sh) - else: - temp = sh - base = temp - else: + if not obj.Base.Shape.isNull(): + base = obj.Base.Shape.copy() + if base.Solids: + pass + elif base.Faces: + if height: + norm = normal.multiply(height) + base = base.extrude(norm) + elif base.Wires: + temp = None + for wire in obj.Base.Shape.Wires: + sh = getbase(wire) + if temp: + temp = temp.oldFuse(sh) + else: + temp = sh + base = temp + if not base: if obj.Length == 0: return + length = obj.Length + if not length: + length = 1 v1 = Vector(0,0,0) - v2 = Vector(obj.Length,0,0) + v2 = Vector(length,0,0) w = Part.Wire(Part.Line(v1,v2).toShape()) base = getbase(w) - + for app in obj.Additions: base = base.oldFuse(app.Shape) app.ViewObject.hide() #to be removed @@ -371,15 +381,17 @@ class _Wall(ArchComponent.Component): if Draft.getType(hole) == "Window": # window if hole.Base and obj.Width: - f = self.getSubVolume(hole.Base,obj.Width) + f = self.getSubVolume(hole.Base,width) base = base.cut(f) elif Draft.isClone(hole,"Window"): - if hole.Objects[0].Base and obj.Width: - f = self.getSubVolume(hole.Objects[0].Base,obj.Width,hole.Placement.Base) + if hole.Objects[0].Base and width: + f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement.Base) base = base.cut(f) - elif hasattr(obj,"Shape"): - base = base.cut(hole.Shape) - hole.ViewObject.hide() # to be removed + elif hasattr(hole,"Shape"): + if not hole.Shape.isNull(): + base = base.cut(hole.Shape) + hole.ViewObject.hide() # to be removed + obj.Shape = base if not fcgeo.isNull(pl): obj.Placement = pl diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 31d7998e6..382d9e3f9 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -119,8 +119,9 @@ class _Window(ArchComponent.Component): wstr = obj.WindowParts[(i*5)+2].split(',') for s in wstr: j = int(s[4:]) - if len(obj.Base.Shape.Wires) >= j: - wires.append(obj.Base.Shape.Wires[j]) + 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: @@ -143,6 +144,7 @@ class _Window(ArchComponent.Component): if zof: zov = fcvec.scaleTo(norm,zof) shape.translate(zov) + print shape shapes.append(shape) obj.Shape = Part.makeCompound(shapes) if not fcgeo.isNull(pl):