Arch: Building now derives from BuildingPart

This commit is contained in:
Yorik van Havre
2018-07-13 10:23:01 -03:00
parent be5e93ddfe
commit c6b3949704
3 changed files with 180 additions and 5 deletions

View File

@@ -300,6 +300,19 @@ class _ViewProviderBuilding(ArchFloor._ViewProviderFloor):
import Arch_rc
return ":/icons/Arch_Building_Tree.svg"
def setupContextMenu(self,vobj,menu):
from PySide import QtCore,QtGui
import Arch_rc
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_BuildingPart.svg"),"Convert to BuildingPart",menu)
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.convertToBuildingPart)
menu.addAction(action1)
def convertToBuildingPart(self):
if hasattr(self,"Object"):
import ArchBuildingPart
from DraftGui import todo
todo.delay(ArchBuildingPart.convertFloors,self.Object)
if FreeCAD.GuiUp:

View File

@@ -48,6 +48,147 @@ __author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"
BuildingTypes = ['Undefined',
'Agricultural - Barn',
'Agricultural - Chicken coop or chickenhouse',
'Agricultural - Cow-shed',
'Agricultural - Farmhouse',
'Agricultural - Granary',
'Agricultural - Greenhouse',
'Agricultural - Hayloft',
'Agricultural - Pigpen or sty',
'Agricultural - Root cellar',
'Agricultural - Shed',
'Agricultural - Silo',
'Agricultural - Stable',
'Agricultural - Storm cellar',
'Agricultural - Well house',
'Agricultural - Underground pit',
'Commercial - Automobile repair shop',
'Commercial - Bank',
'Commercial - Car wash',
'Commercial - Convention center',
'Commercial - Forum',
'Commercial - Gas station',
'Commercial - Hotel',
'Commercial - Market',
'Commercial - Market house',
'Commercial - Skyscraper',
'Commercial - Shop',
'Commercial - Shopping mall',
'Commercial - Supermarket',
'Commercial - Warehouse',
'Commercial - Restaurant',
'Residential - Apartment block',
'Residential - Asylum',
'Residential - Condominium',
'Residential - Dormitory',
'Residential - Duplex',
'Residential - House',
'Residential - Nursing home',
'Residential - Townhouse',
'Residential - Villa',
'Residential - Bungalow',
'Educational - Archive',
'Educational - College classroom building',
'Educational - College gymnasium',
'Educational - College students union',
'Educational - School',
'Educational - Library',
'Educational - Museum',
'Educational - Art gallery',
'Educational - Theater',
'Educational - Amphitheater',
'Educational - Concert hall',
'Educational - Cinema',
'Educational - Opera house',
'Educational - Boarding school',
'Government - Capitol',
'Government - City hall',
'Government - Consulate',
'Government - Courthouse',
'Government - Embassy',
'Government - Fire station',
'Government - Meeting house',
'Government - Moot hall',
'Government - Palace',
'Government - Parliament',
'Government - Police station',
'Government - Post office',
'Government - Prison',
'Industrial - Brewery',
'Industrial - Factory',
'Industrial - Foundry',
'Industrial - Power plant',
'Industrial - Mill',
'Military - Arsenal',
'Military -Barracks',
'Parking - Boathouse',
'Parking - Garage',
'Parking - Hangar',
'Storage - Silo',
'Storage - Hangar',
'Religious - Church',
'Religious - Basilica',
'Religious - Cathedral',
'Religious - Chapel',
'Religious - Oratory',
'Religious - Martyrium',
'Religious - Mosque',
'Religious - Mihrab',
'Religious - Surau',
'Religious - Imambargah',
'Religious - Monastery',
'Religious - Mithraeum',
'Religious - Fire temple',
'Religious - Shrine',
'Religious - Synagogue',
'Religious - Temple',
'Religious - Pagoda',
'Religious - Gurdwara',
'Religious - Hindu temple',
'Transport - Airport terminal',
'Transport - Bus station',
'Transport - Metro station',
'Transport - Taxi station',
'Transport - Railway station',
'Transport - Signal box',
'Transport - Lighthouse',
'Infrastructure - Data centre',
'Power station - Fossil-fuel power station',
'Power station - Nuclear power plant',
'Power station - Geothermal power',
'Power station - Biomass-fuelled power plant',
'Power station - Waste heat power plant',
'Power station - Renewable energy power station',
'Power station - Atomic energy plant',
'Other - Apartment',
'Other - Clinic',
'Other - Community hall',
'Other - Eatery',
'Other - Folly',
'Other - Food court',
'Other - Hospice',
'Other - Hospital',
'Other - Hut',
'Other - Bathhouse',
'Other - Workshop',
'Other - World trade centre'
]
def makeBuildingPart(objectslist=None):
@@ -58,12 +199,14 @@ def makeBuildingPart(objectslist=None):
#obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","BuildingPart")
obj.Label = translate("Arch","BuildingPart")
BuildingPart(obj)
#obj.IfcRole = "Building Storey" # set default to Floor
if FreeCAD.GuiUp:
ViewProviderBuildingPart(obj.ViewObject)
if objectslist:
obj.addObjects(objectslist)
return obj
def makeFloor(objectslist=None,baseobj=None,name="Floor"):
"""overwrites ArchFloor.makeFloor"""
@@ -73,9 +216,22 @@ def makeFloor(objectslist=None,baseobj=None,name="Floor"):
obj.IfcRole = "Building Storey"
return obj
def makeBuilding(objectslist=None,baseobj=None,name="Building"):
"""overwrites ArchBuilding.makeBiulding"""
obj = makeBuildingPart(objectslist)
obj.Label = name
obj.IfcRole = "Building"
obj.addProperty("App::PropertyEnumeration","BuildingType","Arch",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
obj.BuildingType = BuildingTypes
return obj
def convertFloors(floor=None):
"""convert the given Floor (or all Arch Floors from the active document if none is given) into BuildingParts"""
"""convert the given Floor or Building (or all Arch Floors from the active document if none is given) into BuildingParts"""
todel = []
if floor:
@@ -83,9 +239,14 @@ def convertFloors(floor=None):
else:
objset = FreeCAD.ActiveDocument.Objects
for obj in objset:
if Draft.getType(obj) == "Floor":
if Draft.getType(obj) in ["Floor","Building"]:
nobj = makeBuildingPart(obj.Group)
nobj.Role = "Storey"
if Draft.getType(obj) == "Floor":
nobj.IfcRole = "Building Storey"
else:
nobj.IfcRole = "Building"
nobj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
nobj.BuildingType = BuildingTypes
label = obj.Label
for parent in obj.InList:
if hasattr(parent,"Group"):
@@ -106,6 +267,7 @@ def convertFloors(floor=None):
todo.delay(FreeCAD.ActiveDocument.removeObject,n)
class CommandBuildingPart:

View File

@@ -33,8 +33,8 @@ class ArchWorkbench(Workbench):
from DraftTools import translate
# arch tools
self.archtools = ["Arch_Wall","Arch_Structure","Arch_Rebar","Arch_Floor",
"Arch_BuildingPart","Arch_Building","Arch_Site",
self.archtools = ["Arch_Wall","Arch_Structure","Arch_Rebar","Arch_BuildingPart",
"Arch_Floor","Arch_Building","Arch_Site",
"Arch_Window","Arch_Roof","Arch_AxisTools",
"Arch_SectionPlane","Arch_Space","Arch_Stairs",
"Arch_PanelTools","Arch_Equipment",