From c6b39497044ff19b26beaf312167cbcdedc937f8 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 13 Jul 2018 10:23:01 -0300 Subject: [PATCH] Arch: Building now derives from BuildingPart --- src/Mod/Arch/ArchBuilding.py | 13 +++ src/Mod/Arch/ArchBuildingPart.py | 168 ++++++++++++++++++++++++++++++- src/Mod/Arch/InitGui.py | 4 +- 3 files changed, 180 insertions(+), 5 deletions(-) diff --git a/src/Mod/Arch/ArchBuilding.py b/src/Mod/Arch/ArchBuilding.py index 911359e2e8..b0b43922ae 100644 --- a/src/Mod/Arch/ArchBuilding.py +++ b/src/Mod/Arch/ArchBuilding.py @@ -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: diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index b1e5fbfc19..b3cf89fede 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -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: diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py index b619ae6895..53753273a9 100644 --- a/src/Mod/Arch/InitGui.py +++ b/src/Mod/Arch/InitGui.py @@ -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",