Arch: Enabled multilayer walls

This commit is contained in:
Yorik van Havre 2013-10-11 15:11:41 -03:00
parent 7d2b885caf
commit fe06740133
3 changed files with 47 additions and 10 deletions

View File

@ -299,6 +299,21 @@ class Component:
def onChanged(self,obj,prop):
pass
def getSiblings(self,obj):
"returns a list of objects with the same base as this object"
if not hasattr(obj,"Base"):
return []
if not obj.Base:
return []
siblings = []
for o in obj.Base.InList:
if hasattr(o,"Base"):
if o.Base:
if o.Base.Name == obj.Base.Name:
if o.Name != obj.Name:
siblings.append(o)
return siblings
def hideSubobjects(self,obj,prop):
"Hides subobjects when a subobject lists change"

View File

@ -35,6 +35,7 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
given object, which can be a sketch, a draft object, a face or a solid, or no object at
all, then you must provide length, width and height. Align can be "Center","Left" or "Right",
face can be an index number of a face in the base object to base the wall on.'''
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
_Wall(obj)
_ViewProviderWall(obj.ViewObject)
@ -46,8 +47,12 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
obj.Length = length
if width:
obj.Width = width
else:
width = p.GetFloat("WallWidth",200)
if height:
obj.Height = height
else:
p.GetFloat("WallHeight",3000)
obj.Align = align
if obj.Base:
if Draft.getType(obj.Base) != "Space":
@ -380,6 +385,8 @@ class _Wall(ArchComponent.Component):
str(translate("Arch","If True, if this wall is based on a face, it will use its border wire as trace, and disconsider the face.")))
obj.addProperty("App::PropertyInteger","Face","Arch",
str(translate("Arch","The face number of the base object used to build this wall")))
obj.addProperty("App::PropertyLength","Offset","Arch",
str(translate("Arch","The offset between this wall and its baseline (only for left and right alignments)")))
obj.Align = ['Left','Right','Center']
obj.ForceWire = False
self.Type = "Wall"
@ -447,12 +454,20 @@ class _Wall(ArchComponent.Component):
dvec.normalize()
if obj.Align == "Left":
dvec.multiply(width)
if hasattr(obj,"Offset"):
if obj.Offset:
dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset)
wire = DraftGeomUtils.offsetWire(wire,dvec2)
w2 = DraftGeomUtils.offsetWire(wire,dvec)
w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges))
sh = DraftGeomUtils.bind(w1,w2)
elif obj.Align == "Right":
dvec.multiply(width)
dvec = dvec.negative()
if hasattr(obj,"Offset"):
if obj.Offset:
dvec2 = DraftVecUtils.scaleTo(dvec,obj.Offset)
wire = DraftGeomUtils.offsetWire(wire,dvec2)
w2 = DraftGeomUtils.offsetWire(wire,dvec)
w1 = Part.Wire(DraftGeomUtils.sortEdges(wire.Edges))
sh = DraftGeomUtils.bind(w1,w2)

View File

@ -89,20 +89,26 @@ class _CommandWindow:
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
else:
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Window")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
host = None
if hasattr(obj,"Support"):
if obj.Support:
if isinstance(obj.Support,tuple):
s = obj.Support[0]
host = obj.Support[0]
else:
s = obj.Support
w = FreeCAD.ActiveDocument.Objects[-1] # last created object
FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+w.Name+",host=FreeCAD.ActiveDocument."+s.Name+")")
host = obj.Support
obj.Support = None # remove
elif Draft.isClone(obj,"Window"):
if obj.Objects[0].Inlist:
FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+obj.Name+",host=FreeCAD.ActiveDocument."+obj.Objects[0].Inlist[0].Name+")")
host = obj.Objects[0].Inlist[0]
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Window")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("win = Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
if host:
FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+host.Name+")")
siblings = host.Proxy.getSiblings(host)
for sibling in siblings:
FreeCADGui.doCommand("Arch.removeComponents(win,host=FreeCAD.ActiveDocument."+sibling.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
else:
@ -186,10 +192,11 @@ class _Window(ArchComponent.Component):
if base:
if not base.isNull():
obj.Shape = base
def getSubVolume(self,obj,plac=None):
"returns a subvolume for cutting in a base object"
# getting extrusion depth
base = None
if obj.Base: