Arch: Add default storey when exporting to IFC + allow all Arch objects to have Undefined role
This commit is contained in:
parent
686ba7094d
commit
b115d794a7
|
@ -52,7 +52,7 @@ else:
|
|||
# or hydraulic appliances in a building
|
||||
|
||||
# presets
|
||||
Roles = ["Furniture", "Hydro Equipment", "Electric Equipment"]
|
||||
Roles = ["Undefined","Furniture", "Hydro Equipment", "Electric Equipment"]
|
||||
|
||||
|
||||
def makeEquipment(baseobj=None,placement=None,name="Equipment"):
|
||||
|
|
|
@ -49,7 +49,7 @@ __author__ = "Yorik van Havre"
|
|||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
# Possible roles for frames
|
||||
Roles = ['Covering','Member','Railing','Shading Device','Tendon']
|
||||
Roles = ['Undefined','Covering','Member','Railing','Shading Device','Tendon']
|
||||
|
||||
def makeFrame(baseobj,profile,name=translate("Arch","Frame")):
|
||||
"""makeFrame(baseobj,profile,[name]): creates a frame object from a base sketch (or any other object
|
||||
|
|
|
@ -27,7 +27,7 @@ __title__="FreeCAD Arch Space"
|
|||
__author__ = "Yorik van Havre"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
Roles = ["Space"]
|
||||
Roles = ["Undefined","Space"]
|
||||
|
||||
SpaceTypes = [
|
||||
"Undefined",
|
||||
|
|
|
@ -54,7 +54,7 @@ __url__ = "http://www.freecadweb.org"
|
|||
|
||||
|
||||
# Possible roles for structural elements
|
||||
Roles = ["Beam","Column","Slab","Wall","Curtain Wall","Roof","Foundation","Pile","Tendon"]
|
||||
Roles = ["Undefined","Beam","Column","Slab","Wall","Curtain Wall","Roof","Foundation","Pile","Tendon"]
|
||||
|
||||
#Reads preset profiles and categorizes them
|
||||
Categories=[]
|
||||
|
|
|
@ -50,7 +50,7 @@ __author__ = "Yorik van Havre"
|
|||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
# Possible roles for walls
|
||||
Roles = ['Wall','Wall Layer','Beam','Column','Curtain Wall']
|
||||
Roles = ['Undefined','Wall','Wall Layer','Beam','Column','Curtain Wall']
|
||||
|
||||
def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face=None,name="Wall"):
|
||||
'''makeWall([obj],[length],[width],[height],[align],[face],[name]): creates a wall based on the
|
||||
|
|
|
@ -56,7 +56,7 @@ AllowedHosts = ["Wall","Structure","Roof"]
|
|||
WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane",
|
||||
"Sliding 2-pane", "Simple door", "Glass door"]
|
||||
WindowOpeningModes = ["None","Arc 90","Arc 90 inv","Arc 45","Arc 45 inv","Arc 180","Arc 180 inv","Triangle","Triangle inv","Sliding","Sliding inv"]
|
||||
Roles = ["Window","Door"]
|
||||
Roles = ["Undefined","Window","Door"]
|
||||
|
||||
|
||||
def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"):
|
||||
|
|
|
@ -36,6 +36,7 @@ import os,time,tempfile,uuid,FreeCAD,Part,Draft,Arch,math,DraftVecUtils
|
|||
# This module provides tools to import and export IFC files.
|
||||
|
||||
DEBUG = False
|
||||
ADDDEFAULTSTOREY = True
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pyopen = open # because we'll redefine open below
|
||||
|
@ -1017,6 +1018,7 @@ def export(exportList,filename):
|
|||
if obj.Shape:
|
||||
if obj.Shape.Edges and (not obj.Shape.Faces):
|
||||
annotations.append(obj)
|
||||
objectslist = [obj for obj in objectslist if not obj in annotations]
|
||||
objectslist = Arch.pruneIncluded(objectslist)
|
||||
products = {} # { Name: IfcEntity, ... }
|
||||
surfstyles = {} # { (r,g,b): IfcEntity, ... }
|
||||
|
@ -1233,6 +1235,7 @@ def export(exportList,filename):
|
|||
buildings = []
|
||||
floors = []
|
||||
treated = []
|
||||
defaulthost = []
|
||||
for floor in Draft.getObjectsOfType(objectslist,"Floor"):
|
||||
objs = Draft.getGroupContents(floor,walls=True)
|
||||
objs = Arch.pruneIncluded(objs)
|
||||
|
@ -1246,6 +1249,7 @@ def export(exportList,filename):
|
|||
if children:
|
||||
ifcfile.createIfcRelContainedInSpatialStructure(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'StoreyLink','',children,f)
|
||||
floors.append(floor.Name)
|
||||
defaulthost = f
|
||||
for building in Draft.getObjectsOfType(objectslist,"Building"):
|
||||
objs = Draft.getGroupContents(building,walls=True,addgroups=True)
|
||||
objs = Arch.pruneIncluded(objs)
|
||||
|
@ -1267,6 +1271,7 @@ def export(exportList,filename):
|
|||
if childfloors:
|
||||
ifcfile.createIfcRelAggregates(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'BuildingLink','',b,childfloors)
|
||||
buildings.append(b)
|
||||
#defaulthost = b
|
||||
for site in Draft.getObjectsOfType(objectslist,"Site"):
|
||||
objs = Draft.getGroupContents(site,walls=True,addgroups=True)
|
||||
objs = Arch.pruneIncluded(objs)
|
||||
|
@ -1280,6 +1285,8 @@ def export(exportList,filename):
|
|||
childbuildings.append(products[c.Name])
|
||||
treated.append(c.Name)
|
||||
sites.append(products[site.Name])
|
||||
if not defaulthost:
|
||||
defaulthost = products[site.Name]
|
||||
if not sites:
|
||||
if DEBUG: print ("No site found. Adding default site")
|
||||
sites = [ifcfile.createIfcSite(ifcopenshell.guid.compress(uuid.uuid1().hex),history,"Default Site",'',None,None,None,None,"ELEMENT",None,None,None,None,None)]
|
||||
|
@ -1295,7 +1302,10 @@ def export(exportList,filename):
|
|||
if not(Draft.getType(FreeCAD.ActiveDocument.getObject(k)) in ["Site","Building","Floor"]):
|
||||
untreated.append(v)
|
||||
if untreated:
|
||||
ifcfile.createIfcRelContainedInSpatialStructure(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'BuildingLinkUnassignedObjects','',untreated,buildings[0])
|
||||
if not defaulthost:
|
||||
defaulthost = ifcfile.createIfcBuildingStorey(ifcopenshell.guid.compress(uuid.uuid1().hex),history,"Default Storey",'',None,None,None,None,"ELEMENT",None)
|
||||
ifcfile.createIfcRelAggregates(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'DefaultStoreyLink','',buildings[0],[defaulthost])
|
||||
ifcfile.createIfcRelContainedInSpatialStructure(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'UnassignedObjectsLink','',untreated,defaulthost)
|
||||
|
||||
# materials
|
||||
materials = {}
|
||||
|
@ -1359,6 +1369,7 @@ def export(exportList,filename):
|
|||
# 2D objects
|
||||
|
||||
if EXPORT_2D:
|
||||
annos = []
|
||||
curvestyles = {}
|
||||
if annotations and DEBUG: print ("exporting 2D objects...")
|
||||
for anno in annotations:
|
||||
|
@ -1403,6 +1414,13 @@ def export(exportList,filename):
|
|||
shp = ifcfile.createIfcShapeRepresentation(context,'Annotation','Annotation2D',reps)
|
||||
rep = ifcfile.createIfcProductDefinitionShape(None,None,[shp])
|
||||
ann = ifcfile.createIfcAnnotation(ifcopenshell.guid.compress(uuid.uuid1().hex),history,anno.Label.encode('utf8'),'',None,gpl,rep)
|
||||
annos.append(ann)
|
||||
if annos:
|
||||
if not defaulthost:
|
||||
defaulthost = ifcfile.createIfcBuildingStorey(ifcopenshell.guid.compress(uuid.uuid1().hex),history,"Default Storey",'',None,None,None,None,"ELEMENT",None)
|
||||
ifcfile.createIfcRelAggregates(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'DefaultStoreyLink','',buildings[0],[defaulthost])
|
||||
ifcfile.createIfcRelContainedInSpatialStructure(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'AnnotationsLink','',annos,defaulthost)
|
||||
|
||||
|
||||
if DEBUG: print("writing ",filename,"...")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user