Arch: Several bugfixes in arch objects

This commit is contained in:
Yorik van Havre 2012-06-03 23:44:20 -03:00
parent 8941868e0d
commit b701bfd1e1
4 changed files with 69 additions and 63 deletions

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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"