Arch: Several bugfixes in arch objects
This commit is contained in:
parent
8941868e0d
commit
b701bfd1e1
|
@ -257,9 +257,9 @@ class Component:
|
||||||
obj.addProperty("App::PropertyLink","Base","Base",
|
obj.addProperty("App::PropertyLink","Base","Base",
|
||||||
"The base object this component is built upon")
|
"The base object this component is built upon")
|
||||||
obj.addProperty("App::PropertyLinkList","Additions","Base",
|
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",
|
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
|
obj.Proxy = self
|
||||||
self.Type = "Component"
|
self.Type = "Component"
|
||||||
self.Subvolume = None
|
self.Subvolume = None
|
||||||
|
|
|
@ -163,17 +163,13 @@ class _Structure(ArchComponent.Component):
|
||||||
base = Part.Face(base)
|
base = Part.Face(base)
|
||||||
base = base.extrude(normal)
|
base = base.extrude(normal)
|
||||||
for app in obj.Additions:
|
for app in obj.Additions:
|
||||||
base = base.oldFuse(app.Shape)
|
if hasattr(app,"Shape"):
|
||||||
app.ViewObject.hide() # to be removed
|
if not app.Shape.isNull():
|
||||||
|
base = base.fuse(app.Shape)
|
||||||
|
app.ViewObject.hide() # to be removed
|
||||||
for hole in obj.Subtractions:
|
for hole in obj.Subtractions:
|
||||||
cut = False
|
if hasattr(hole,"Shape"):
|
||||||
if hasattr(hole,"Proxy"):
|
if not hole.Shape.isNull():
|
||||||
if hasattr(hole.Proxy,"Subvolume"):
|
|
||||||
if hole.Proxy.Subvolume:
|
|
||||||
base = base.cut(hole.Proxy.Subvolume)
|
|
||||||
cut = True
|
|
||||||
if not cut:
|
|
||||||
if hasattr(obj,"Shape"):
|
|
||||||
base = base.cut(hole.Shape)
|
base = base.cut(hole.Shape)
|
||||||
hole.ViewObject.hide() # to be removed
|
hole.ViewObject.hide() # to be removed
|
||||||
if base:
|
if base:
|
||||||
|
@ -186,7 +182,9 @@ class _Structure(ArchComponent.Component):
|
||||||
fsh.append(sh)
|
fsh.append(sh)
|
||||||
obj.Shape = Part.makeCompound(fsh)
|
obj.Shape = Part.makeCompound(fsh)
|
||||||
else:
|
else:
|
||||||
obj.Shape = base
|
if not base.isNull():
|
||||||
|
base = base.removeSplitter()
|
||||||
|
obj.Shape = base
|
||||||
if not DraftGeomUtils.isNull(pl): obj.Placement = pl
|
if not DraftGeomUtils.isNull(pl): obj.Placement = pl
|
||||||
|
|
||||||
class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
||||||
|
|
|
@ -272,20 +272,23 @@ class _Wall(ArchComponent.Component):
|
||||||
"returns a subvolume from a base object"
|
"returns a subvolume from a base object"
|
||||||
import Part
|
import Part
|
||||||
max_length = 0
|
max_length = 0
|
||||||
|
f = None
|
||||||
for w in base.Shape.Wires:
|
for w in base.Shape.Wires:
|
||||||
if w.BoundBox.DiagonalLength > max_length:
|
if w.BoundBox.DiagonalLength > max_length:
|
||||||
max_length = w.BoundBox.DiagonalLength
|
max_length = w.BoundBox.DiagonalLength
|
||||||
f = w
|
f = w
|
||||||
f = Part.Face(f)
|
if f:
|
||||||
n = f.normalAt(0,0)
|
f = Part.Face(f)
|
||||||
v1 = DraftVecUtils.scaleTo(n,width)
|
n = f.normalAt(0,0)
|
||||||
f.translate(v1)
|
v1 = DraftVecUtils.scaleTo(n,width)
|
||||||
v2 = DraftVecUtils.neg(v1)
|
f.translate(v1)
|
||||||
v2 = DraftVecUtils.scale(v1,-2)
|
v2 = DraftVecUtils.neg(v1)
|
||||||
f = f.extrude(v2)
|
v2 = DraftVecUtils.scale(v1,-2)
|
||||||
if delta:
|
f = f.extrude(v2)
|
||||||
f.translate(delta)
|
if delta:
|
||||||
return f
|
f.translate(delta)
|
||||||
|
return f
|
||||||
|
return None
|
||||||
|
|
||||||
def createGeometry(self,obj):
|
def createGeometry(self,obj):
|
||||||
"builds the wall shape"
|
"builds the wall shape"
|
||||||
|
@ -368,27 +371,29 @@ class _Wall(ArchComponent.Component):
|
||||||
else:
|
else:
|
||||||
temp = sh
|
temp = sh
|
||||||
base = temp
|
base = temp
|
||||||
base = base.removeSplitter()
|
|
||||||
|
|
||||||
for app in obj.Additions:
|
for app in obj.Additions:
|
||||||
base = base.oldFuse(app.Shape)
|
base = base.fuse(app.Shape)
|
||||||
app.ViewObject.hide() #to be removed
|
app.ViewObject.hide() #to be removed
|
||||||
for hole in obj.Subtractions:
|
for hole in obj.Subtractions:
|
||||||
if Draft.getType(hole) == "Window":
|
if Draft.getType(hole) == "Window":
|
||||||
# window
|
# window
|
||||||
if hole.Base and obj.Width:
|
if hole.Base and obj.Width:
|
||||||
f = self.getSubVolume(hole.Base,width)
|
f = self.getSubVolume(hole.Base,width)
|
||||||
base = base.cut(f)
|
if f:
|
||||||
|
base = base.cut(f)
|
||||||
elif Draft.isClone(hole,"Window"):
|
elif Draft.isClone(hole,"Window"):
|
||||||
if hole.Objects[0].Base and width:
|
if hole.Objects[0].Base and width:
|
||||||
f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement.Base)
|
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"):
|
elif hasattr(hole,"Shape"):
|
||||||
if not hole.Shape.isNull():
|
if not hole.Shape.isNull():
|
||||||
base = base.cut(hole.Shape)
|
base = base.cut(hole.Shape)
|
||||||
hole.ViewObject.hide() # to be removed
|
hole.ViewObject.hide() # to be removed
|
||||||
|
|
||||||
if base:
|
if base:
|
||||||
|
base.removeSplitter()
|
||||||
obj.Shape = base
|
obj.Shape = base
|
||||||
if not DraftGeomUtils.isNull(pl):
|
if not DraftGeomUtils.isNull(pl):
|
||||||
obj.Placement = pl
|
obj.Placement = pl
|
||||||
|
|
|
@ -117,6 +117,7 @@ class _Window(ArchComponent.Component):
|
||||||
obj.addProperty("App::PropertyStringList","WindowParts","Base",
|
obj.addProperty("App::PropertyStringList","WindowParts","Base",
|
||||||
str(translate("Arch","the components of this window")))
|
str(translate("Arch","the components of this window")))
|
||||||
self.Type = "Window"
|
self.Type = "Window"
|
||||||
|
obj.Proxy = self
|
||||||
|
|
||||||
def execute(self,obj):
|
def execute(self,obj):
|
||||||
self.createGeometry(obj)
|
self.createGeometry(obj)
|
||||||
|
@ -130,43 +131,45 @@ class _Window(ArchComponent.Component):
|
||||||
pl = obj.Placement
|
pl = obj.Placement
|
||||||
if obj.Base:
|
if obj.Base:
|
||||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||||
if obj.WindowParts and (len(obj.WindowParts)%5 == 0):
|
if hasattr(obj,"WindowParts"):
|
||||||
shapes = []
|
if obj.WindowParts and (len(obj.WindowParts)%5 == 0):
|
||||||
for i in range(len(obj.WindowParts)/5):
|
shapes = []
|
||||||
wires = []
|
for i in range(len(obj.WindowParts)/5):
|
||||||
wstr = obj.WindowParts[(i*5)+2].split(',')
|
wires = []
|
||||||
for s in wstr:
|
wstr = obj.WindowParts[(i*5)+2].split(',')
|
||||||
j = int(s[4:])
|
for s in wstr:
|
||||||
if obj.Base.Shape.Wires:
|
j = int(s[4:])
|
||||||
if len(obj.Base.Shape.Wires) >= j:
|
if obj.Base.Shape.Wires:
|
||||||
wires.append(obj.Base.Shape.Wires[j])
|
if len(obj.Base.Shape.Wires) >= j:
|
||||||
if wires:
|
wires.append(obj.Base.Shape.Wires[j])
|
||||||
max_length = 0
|
if wires:
|
||||||
for w in wires:
|
max_length = 0
|
||||||
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:
|
for w in wires:
|
||||||
f = Part.Face(w)
|
if w.BoundBox.DiagonalLength > max_length:
|
||||||
f = f.extrude(exv)
|
max_length = w.BoundBox.DiagonalLength
|
||||||
shape = shape.cut(f)
|
ext = w
|
||||||
if obj.WindowParts[(i*5)+4]:
|
wires.remove(ext)
|
||||||
zof = float(obj.WindowParts[(i*5)+4])
|
shape = Part.Face(ext)
|
||||||
if zof:
|
norm = shape.normalAt(0,0)
|
||||||
zov = DraftVecUtils.scaleTo(norm,zof)
|
thk = float(obj.WindowParts[(i*5)+3])
|
||||||
shape.translate(zov)
|
if thk:
|
||||||
print shape
|
exv = DraftVecUtils.scaleTo(norm,thk)
|
||||||
shapes.append(shape)
|
shape = shape.extrude(exv)
|
||||||
obj.Shape = Part.makeCompound(shapes)
|
for w in wires:
|
||||||
if not DraftGeomUtils.isNull(pl):
|
f = Part.Face(w)
|
||||||
obj.Placement = pl
|
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):
|
class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||||
"A View Provider for the Window object"
|
"A View Provider for the Window object"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user