Draft: Better fix to buggy Move/rotate of Arch BuilfingParts

This commit is contained in:
Yorik van Havre
2018-12-01 12:12:22 -02:00
parent e890a50ff0
commit 1fa9e61ce4
2 changed files with 19 additions and 12 deletions

View File

@@ -359,7 +359,7 @@ def shapify(obj):
FreeCAD.ActiveDocument.recompute()
return newobj
def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False):
def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False,noarchchild=False):
'''getGroupContents(objectlist,[walls,addgroups]): if any object of the given list
is a group, its content is appened to the list, which is returned. If walls is True,
walls and structures are also scanned for included windows or rebars. If addgroups
@@ -387,7 +387,7 @@ def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False):
objectslist = [objectslist]
for obj in objectslist:
if obj:
if obj.isDerivedFrom("App::DocumentObjectGroup") or ((getType(obj) in ["BuildingPart","Space","Site"]) and hasattr(obj,"Group")):
if obj.isDerivedFrom("App::DocumentObjectGroup") or ((getType(obj) in ["Building","BuildingPart","Space","Site"]) and hasattr(obj,"Group")):
if getType(obj) == "Site":
if obj.Shape:
newlist.append(obj)
@@ -397,7 +397,10 @@ def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False):
else:
if addgroups or (spaces and (getType(obj) == "Space")):
newlist.append(obj)
newlist.extend(getGroupContents(obj.Group,walls,addgroups))
if noarchchild and (getType(obj) in ["Building","BuildingPart"]):
pass
else:
newlist.extend(getGroupContents(obj.Group,walls,addgroups))
else:
#print("adding ",obj.Name)
newlist.append(obj)
@@ -1432,6 +1435,15 @@ def move(objectslist,vector,copy=False):
else:
newobj = obj
newobj.Position = obj.Position.add(vector)
elif getType(obj) == "DraftText":
if copy:
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))
newobj.Text = obj.Text
if gui:
formatObject(newobj,obj)
else:
newobj = obj
newobj.Position = obj.Position.add(vector)
elif getType(obj) == "Dimension":
if copy:
newobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",getRealName(obj.Name))

View File

@@ -376,6 +376,8 @@ class SelectPlane(DraftTool):
if o.Visibility != (v == "True"):
FreeCADGui.doCommand("FreeCADGui.ActiveDocument.getObject(\""+k+"\").Visibility = "+v)
self.display(plane.axis)
self.ui.wplabel.setText(sel.Object.Label)
self.ui.wplabel.setToolTip(translate("draft", "Current working plane:",utf8_decode=True)+self.ui.wplabel.text())
self.finish()
return
elif sel.HasSubObjects:
@@ -2363,14 +2365,7 @@ class Move(Modifier):
def proceed(self):
if self.call: self.view.removeEventCallback("SoEvent",self.call)
self.sel = FreeCADGui.Selection.getSelection()
# testing for special case: only Arch groups in selection
onlyarchgroups = True
for o in self.sel:
if not(Draft.getType(o) in ["Floor","BuildingPart","Building","Site"]):
onlyarchgroups = False
if not onlyarchgroups:
# arch groups can be moved, no need to add their children
self.sel = Draft.getGroupContents(self.sel,addgroups=True,spaces=True)
self.sel = Draft.getGroupContents(self.sel,addgroups=True,spaces=True,noarchchild=True)
self.ui.pointUi(self.name)
self.ui.modUi()
if self.copymode:
@@ -2527,7 +2522,7 @@ class Rotate(Modifier):
def proceed(self):
if self.call: self.view.removeEventCallback("SoEvent",self.call)
self.sel = FreeCADGui.Selection.getSelection()
self.sel = Draft.getGroupContents(self.sel,addgroups=True,spaces=True)
self.sel = Draft.getGroupContents(self.sel,addgroups=True,spaces=True,noarchchild=True)
self.step = 0
self.center = None
self.ui.arcUi()