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:
parent
1f3c2ef2c8
commit
7425394df9
|
@ -201,30 +201,44 @@ class _CommandBuilding:
|
||||||
|
|
||||||
def Activated(self):
|
def Activated(self):
|
||||||
sel = FreeCADGui.Selection.getSelection()
|
sel = FreeCADGui.Selection.getSelection()
|
||||||
ok = False
|
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||||
if (len(sel) == 1):
|
link = p.GetBool("FreeLinking",False)
|
||||||
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
|
buildingobj = []
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
|
warning = False
|
||||||
FreeCADGui.addModule("Arch")
|
for obj in sel :
|
||||||
FreeCADGui.doCommand("obj = Arch.makeBuilding()")
|
if not Draft.getType(obj) in ["Site", "Building"] :
|
||||||
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
|
buildingobj.append(obj)
|
||||||
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
|
else :
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
if link == True :
|
||||||
ok = True
|
buildingobj.append(obj)
|
||||||
if not ok:
|
else:
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch"," Create Building"))
|
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 = "[ "
|
ss = "[ "
|
||||||
for o in sel:
|
for o in buildingobj:
|
||||||
if len(ss) > 1:
|
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
|
||||||
ss += ","
|
|
||||||
ss += "FreeCAD.ActiveDocument."+o.Name
|
|
||||||
ss += "]"
|
ss += "]"
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
|
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Building"))
|
||||||
FreeCADGui.addModule("Arch")
|
FreeCADGui.addModule("Arch")
|
||||||
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
|
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
FreeCAD.ActiveDocument.recompute()
|
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):
|
class _Building(ArchFloor._Floor):
|
||||||
"The Building object"
|
"The Building object"
|
||||||
def __init__(self,obj):
|
def __init__(self,obj):
|
||||||
|
|
|
@ -59,29 +59,44 @@ class _CommandFloor:
|
||||||
|
|
||||||
def Activated(self):
|
def Activated(self):
|
||||||
sel = FreeCADGui.Selection.getSelection()
|
sel = FreeCADGui.Selection.getSelection()
|
||||||
ok = False
|
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||||
if (len(sel) == 1):
|
link = p.GetBool("FreeLinking",False)
|
||||||
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
|
floorobj = []
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
|
warning = False
|
||||||
FreeCADGui.addModule("Arch")
|
for obj in sel :
|
||||||
FreeCADGui.doCommand("obj = Arch.makeFloor()")
|
if not Draft.getType(obj) in ["Site", "Building","Floor"] :
|
||||||
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
|
floorobj.append(obj)
|
||||||
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
|
else :
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
if link == True :
|
||||||
ok = True
|
floorobj.append(obj)
|
||||||
if not ok:
|
else:
|
||||||
|
warning = True
|
||||||
|
if warning :
|
||||||
|
message = "You can put anything but Site, Building, Floor object in a Floor object.\n\
|
||||||
|
Floor object are not allowed to accept Site, Building or Floor object.\n\
|
||||||
|
Site, Building and Floor objects will be removed from the selection.\n\
|
||||||
|
You can change that in the preferences.\n"
|
||||||
|
self.printMessage( message )
|
||||||
|
if sel and len(floorobj) == 0:
|
||||||
|
message = "There is no valid object in the selection.\n\
|
||||||
|
Floor creation aborted.\n"
|
||||||
|
self.printMessage( message )
|
||||||
|
else :
|
||||||
ss = "[ "
|
ss = "[ "
|
||||||
for o in sel:
|
for o in floorobj:
|
||||||
if len(ss) > 1:
|
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
|
||||||
ss += ","
|
|
||||||
ss += "FreeCAD.ActiveDocument."+o.Name
|
|
||||||
ss += "]"
|
ss += "]"
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
|
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Floor"))
|
||||||
FreeCADGui.addModule("Arch")
|
FreeCADGui.addModule("Arch")
|
||||||
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
|
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
|
||||||
|
def printMessage(self, message):
|
||||||
|
FreeCAD.Console.PrintMessage(translate("Arch", message))
|
||||||
|
if FreeCAD.GuiUp :
|
||||||
|
reply = QtGui.QMessageBox.information(None,"", message)
|
||||||
|
|
||||||
class _Floor:
|
class _Floor:
|
||||||
"The Floor object"
|
"The Floor object"
|
||||||
def __init__(self,obj):
|
def __init__(self,obj):
|
||||||
|
|
|
@ -61,26 +61,32 @@ class _CommandSite:
|
||||||
|
|
||||||
def Activated(self):
|
def Activated(self):
|
||||||
sel = FreeCADGui.Selection.getSelection()
|
sel = FreeCADGui.Selection.getSelection()
|
||||||
ok = False
|
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||||
if (len(sel) == 1):
|
link = p.GetBool("FreeLinking",False)
|
||||||
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
|
siteobj = []
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
|
warning = False
|
||||||
FreeCADGui.addModule("Arch")
|
for obj in sel :
|
||||||
FreeCADGui.doCommand("obj = Arch.makeSite()")
|
if Draft.getType(obj) == "Building":
|
||||||
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
|
siteobj.append(obj)
|
||||||
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
|
else :
|
||||||
|
if link == True :
|
||||||
nobj = makeSite()
|
siteobj.append(obj)
|
||||||
ArchCommands.copyProperties(sel[0],nobj)
|
else:
|
||||||
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
|
warning = True
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
if warning :
|
||||||
ok = True
|
message = "Please select only Building objects or nothing!\n\
|
||||||
if not ok:
|
Site are not allowed to accept other object than Building.\n\
|
||||||
|
Other objects will be removed from the selection.\n\
|
||||||
|
You can change that in the preferences."
|
||||||
|
self.printMessage( message )
|
||||||
|
if sel and len(siteobj) == 0:
|
||||||
|
message = "There is no valid object in the selection.\n\
|
||||||
|
Site creation aborted."
|
||||||
|
self.printMessage( message )
|
||||||
|
else :
|
||||||
ss = "[ "
|
ss = "[ "
|
||||||
for o in sel:
|
for o in siteobj:
|
||||||
if len(ss) > 1:
|
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
|
||||||
ss += ","
|
|
||||||
ss += "FreeCAD.ActiveDocument."+o.Name
|
|
||||||
ss += "]"
|
ss += "]"
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
|
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
|
||||||
FreeCADGui.addModule("Arch")
|
FreeCADGui.addModule("Arch")
|
||||||
|
@ -88,6 +94,11 @@ class _CommandSite:
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
|
||||||
|
def printMessage(self, message):
|
||||||
|
FreeCAD.Console.PrintMessage(translate("Arch", message))
|
||||||
|
if FreeCAD.GuiUp :
|
||||||
|
reply = QtGui.QMessageBox.information(None,"", message)
|
||||||
|
|
||||||
class _Site(ArchFloor._Floor):
|
class _Site(ArchFloor._Floor):
|
||||||
"The Site object"
|
"The Site object"
|
||||||
def __init__(self,obj):
|
def __init__(self,obj):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user