Arch: Fix Site, Building, Floor objects creation

-New param : GetBool("FreeLinking",False), unavailable in pref see
parameters
-by default :
allow create Site on Building only
deny create Building on Site or Building
deny create Floor on Site, Building,Floor
-option:
allow create and linking what you want (until non-DAG)
This commit is contained in:
Jonathan Wiedemann
2016-07-08 13:12:29 +02:00
committed by Yorik van Havre
parent 1ebe48440b
commit 3b5edef72d
3 changed files with 96 additions and 56 deletions

View File

@@ -201,30 +201,44 @@ class _CommandBuilding:
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
ok = False
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeBuilding()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
FreeCAD.ActiveDocument.commitTransaction()
ok = True
if not ok:
FreeCAD.ActiveDocument.openTransaction(translate("Arch"," Create Building"))
ss = "["
for o in sel:
if len(ss) > 1:
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
link = p.GetBool("FreeLinking",False)
buildingobj = []
warning = False
for obj in sel :
if not Draft.getType(obj) in ["Site", "Building"] :
buildingobj.append(obj)
else :
if link == True :
buildingobj.append(obj)
else:
warning = True
if warning :
message = "You can put anything but Site and Building object in a Building object.\n\
Building object are not allowed to accept Site and Building object.\n\
Site and Building objects will be removed from the selection.\n\
You can change that in the preferences.\n"
self.printMessage( message )
if sel and len(buildingobj) == 0:
message = "There is no valid object in the selection.\n\
Building creation aborted.\n"
self.printMessage( message )
else :
ss = "[ "
for o in buildingobj:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Building"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def printMessage(self, message):
FreeCAD.Console.PrintMessage(translate("Arch", message))
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information(None,"", message)
class _Building(ArchFloor._Floor):
"The Building object"
def __init__(self,obj):