Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arch: Fix Site, Building, Floor objects creation #210

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions src/Mod/Arch/ArchBuilding.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf8 -*-

#***************************************************************************
#* *
#* Copyright (c) 2011 *
Expand Down Expand Up @@ -201,25 +203,34 @@ def IsActive(self):

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 = translate( "Arch" , "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" )
ArchCommands.printMessage( message )
if sel and len(buildingobj) == 0:
message = translate( "Arch" , "There is no valid object in the selection.\n\
Building creation aborted.\n" )
ArchCommands.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()
Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Arch/ArchCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,16 @@ def getExtrusionData(shape):
return [faces[p[0]][0],faces[p[1]][0].CenterOfMass.sub(faces[p[0]][0].CenterOfMass)]
return None

def printMessage( message ):
FreeCAD.Console.PrintMessage( message )
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.information( None , "" , message.decode('utf8') )

def printWarning( message ):
FreeCAD.Console.PrintMessage( message )
if FreeCAD.GuiUp :
reply = QtGui.QMessageBox.warning( None , "" , message.decode('utf8') )


# command definitions ###############################################

Expand Down
48 changes: 30 additions & 18 deletions src/Mod/Arch/ArchFloor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf8 -*-

#***************************************************************************
#* *
#* Copyright (c) 2011 *
Expand Down Expand Up @@ -59,28 +61,38 @@ def IsActive(self):

def Activated(self):
sel = FreeCADGui.Selection.getSelection()
ok = False
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeFloor()")
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:
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)
floorobj = []
warning = False
for obj in sel :
if not Draft.getType(obj) in ["Site", "Building"] :
floorobj.append(obj)
else :
if link == True :
floorobj.append(obj)
else:
warning = True
if warning :
message = translate( "Arch" , "You can put anything but Site, Building, Floor object in a Floor object.\n\
Floor object are not allowed to accept Site or Building object.\n\
Site, Building and Floor objects will be removed from the selection.\n\
You can change that in the preferences.\n" )
ArchCommands.printMessage( message )
if sel and len(floorobj) == 0:
message = translate( "Arch" , "There is no valid object in the selection.\n\
Floor creation aborted.\n" )
ArchCommands.printMessage( message )
else :
ss = "[ "
for o in floorobj:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Floor"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
FreeCAD.ActiveDocument.recompute()

class _Floor:
"The Floor object"
Expand Down
48 changes: 28 additions & 20 deletions src/Mod/Arch/ArchSite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf8 -*-

#***************************************************************************
#* *
#* Copyright (c) 2011 *
Expand Down Expand Up @@ -61,26 +63,32 @@ def IsActive(self):

def Activated(self):
sel = FreeCADGui.Selection.getSelection()
ok = False
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Building","Floor"]:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeSite()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')

nobj = makeSite()
ArchCommands.copyProperties(sel[0],nobj)
FreeCAD.ActiveDocument.removeObject(sel[0].Name)
FreeCAD.ActiveDocument.commitTransaction()
ok = True
if not ok:
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)
siteobj = []
warning = False
for obj in sel :
if Draft.getType(obj) == "Building":
siteobj.append(obj)
else :
if link == True :
siteobj.append(obj)
else:
warning = True
if warning :
message = translate( "Arch" , "Please select only Building objects or nothing!\n\
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." )
ArchCommands.printMessage( message )
if sel and len(siteobj) == 0:
message = translate( "Arch" , "There is no valid object in the selection.\n\
Site creation aborted." )
ArchCommands.printMessage( message )
else :
ss = "[ "
for o in siteobj:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
FreeCADGui.addModule("Arch")
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/importDXF.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def errorDXFLib(gui):
Or download these libraries manually, as explained on
https://github.com/yorikvanhavre/Draft-dxf-importer
To enabled FreeCAD to download these libraries, answer Yes.""")
reply = QtGui.QMessageBox.question(None,"",message,
reply = QtGui.QMessageBox.question(None,"",message.decode('utf8'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
p.SetBool("dxfAllowDownload",True)
Expand Down