Arch: MergeWalls tool can now merge a single wall with its own subwalls

This commit is contained in:
Yorik van Havre 2013-10-08 18:40:23 -03:00
parent 0375c66986
commit 7bef06f329
2 changed files with 34 additions and 9 deletions

View File

@ -85,6 +85,7 @@ def joinWalls(walls,delete=False):
for n in deleteList:
FreeCAD.ActiveDocument.removeObject(n)
FreeCAD.ActiveDocument.recompute()
base.ViewObject.show()
return base
def mergeShapes(w1,w2):
@ -331,9 +332,26 @@ class _CommandMergeWalls:
def Activated(self):
walls = FreeCADGui.Selection.getSelection()
if len(walls) < 2:
FreeCAD.Console.PrintMessage(str(translate("Arch","You must select at least 2 walls")))
return
if len(walls) == 1:
if Draft.getType(walls[0]) == "Wall":
ostr = "FreeCAD.ActiveDocument."+ walls[0].Name
ok = False
for o in walls[0].Additions:
if Draft.getType(o) == "Wall":
ostr += ",FreeCAD.ActiveDocument." + o.Name
ok = True
if ok:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Merge Wall")))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.joinWalls(["+ostr+"],delete=True)")
FreeCAD.ActiveDocument.commitTransaction()
return
else:
FreeCAD.Console.PrintWarning(str(translate("Arch","The selected wall contain no subwall to merge")))
return
else:
FreeCAD.Console.PrintWarning(str(translate("Arch","Please select only wall objects")))
return
for w in walls:
if Draft.getType(w) != "Wall":
FreeCAD.Console.PrintMessage(str(translate("Arch","Please select only wall objects")))
@ -342,11 +360,8 @@ class _CommandMergeWalls:
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)")
FreeCAD.ActiveDocument.commitTransaction()
class _Wall(ArchComponent.Component):
"The Wall object"
def __init__(self,obj):

View File

@ -442,6 +442,12 @@ class Snapper:
if ob:
if ob.isDerivedFrom("Part::Feature"):
edges = ob.Shape.Edges
if Draft.getType(ob) == "Wall":
for so in [ob]+ob.Additions:
if Draft.getType(so) == "Wall":
if so.Base:
edges.extend(so.Base.Shape.Edges)
edges.reverse()
if (not self.maxEdges) or (len(edges) <= self.maxEdges):
for e in edges:
if DraftGeomUtils.geomType(e) == "Line":
@ -519,6 +525,7 @@ class Snapper:
else:
self.extLine2.p1(p0)
self.extLine2.p2(p)
self.extLine.p2(p)
self.extLine2.on()
return p
return None
@ -864,7 +871,10 @@ class Snapper:
# setup trackers if needed
if not self.constrainLine:
self.constrainLine = DraftTrackers.lineTracker(dotted=True)
if self.snapStyle:
self.constrainLine = DraftTrackers.lineTracker(scolor=FreeCADGui.draftToolBar.getDefaultColor("snap"))
else:
self.constrainLine = DraftTrackers.lineTracker(dotted=True)
# setting basepoint
if not basepoint: