Arch: Renamed property IfcRole to IfcType

This commit is contained in:
Yorik van Havre
2019-04-09 15:53:01 -03:00
parent 9d386f8f9a
commit 506cfd9bd2
20 changed files with 156 additions and 168 deletions

View File

@@ -270,7 +270,7 @@ class _Building(ArchFloor._Floor):
ArchFloor._Floor.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Building"
obj.IfcType = "Building"
def setProperties(self,obj):

View File

@@ -202,7 +202,7 @@ def makeBuildingPart(objectslist=None,baseobj=None,name="BuildingPart"):
#obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","BuildingPart")
obj.Label = translate("Arch","BuildingPart")
BuildingPart(obj)
#obj.IfcRole = "Building Storey" # set default to Floor
#obj.IfcType = "Building Storey" # set default to Floor
if FreeCAD.GuiUp:
ViewProviderBuildingPart(obj.ViewObject)
if objectslist:
@@ -216,7 +216,7 @@ def makeFloor(objectslist=None,baseobj=None,name="Floor"):
obj = makeBuildingPart(objectslist)
obj.Label = name
obj.IfcRole = "Building Storey"
obj.IfcType = "Building Storey"
return obj
@@ -226,7 +226,7 @@ def makeBuilding(objectslist=None,baseobj=None,name="Building"):
obj = makeBuildingPart(objectslist)
obj.Label = name
obj.IfcRole = "Building"
obj.IfcType = "Building"
obj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
obj.BuildingType = BuildingTypes
if FreeCAD.GuiUp:
@@ -248,9 +248,9 @@ def convertFloors(floor=None):
if Draft.getType(obj) in ["Floor","Building"]:
nobj = makeBuildingPart(obj.Group)
if Draft.getType(obj) == "Floor":
nobj.IfcRole = "Building Storey"
nobj.IfcType = "Building Storey"
else:
nobj.IfcRole = "Building"
nobj.IfcType = "Building"
nobj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
nobj.BuildingType = BuildingTypes
label = obj.Label
@@ -329,20 +329,13 @@ class BuildingPart:
obj.addProperty("App::PropertyLength","LevelOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The level of the (0,0,0) point of this level"))
if not "Area" in pl:
obj.addProperty("App::PropertyArea","Area", "BuildingPart",QT_TRANSLATE_NOOP("App::Property","The computed floor area of this floor"))
if not "IfcRole" in pl:
obj.addProperty("App::PropertyEnumeration","IfcRole","Component",QT_TRANSLATE_NOOP("App::Property","The role of this object"))
import ArchComponent
obj.IfcRole = ArchComponent.IfcRoles
if not "Description" in pl:
obj.addProperty("App::PropertyString","Description","Component",QT_TRANSLATE_NOOP("App::Property","An optional description for this component"))
if not "Tag" in pl:
obj.addProperty("App::PropertyString","Tag","Component",QT_TRANSLATE_NOOP("App::Property","An optional tag for this component"))
if not "IfcAttributes" in pl:
obj.addProperty("App::PropertyMap","IfcAttributes","Component",QT_TRANSLATE_NOOP("App::Property","Custom IFC properties and attributes"))
if not "Shape" in pl:
obj.addProperty("Part::PropertyPartShape","Shape","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The shape of this object"))
if not "IfcProperties" in pl:
obj.addProperty("App::PropertyMap","IfcProperties","Component",QT_TRANSLATE_NOOP("App::Property","Stores IFC properties"))
self.Type = "BuildingPart"
def onDocumentRestored(self,obj):
@@ -499,9 +492,9 @@ class ViewProviderBuildingPart:
import Arch_rc
if hasattr(self,"Object"):
if self.Object.IfcRole == "Building Storey":
if self.Object.IfcType == "Building Storey":
return ":/icons/Arch_Floor_Tree.svg"
elif self.Object.IfcRole == "Building":
elif self.Object.IfcType == "Building":
return ":/icons/Arch_Building_Tree.svg"
return ":/icons/Arch_BuildingPart_Tree.svg"

View File

@@ -47,36 +47,14 @@ else:
# This module provides the base Arch component class, that
# is shared by all of the Arch BIM objects
IfcRoles = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in ArchIFCSchema.IfcProducts.keys()]
def convertOldComponents(objs=[]):
"""converts Arch Objects with a Role property to the new IfcRole.
if no object is given, all objects of the active document are converted"""
if not objs:
objs = FreeCAD.ActiveDocument.Objects
if not isinstance(objs,list):
objs = [objs]
for obj in objs:
if "Role" in obj.PropertiesList:
obj.addProperty("App::PropertyEnumeration","IfcRole","Component",QT_TRANSLATE_NOOP("App::Property","The role of this object"))
obj.IfcRole = IfcRoles
if obj.Role in IfcRoles:
obj.IfcRole = obj.Role
else:
FreeCAD.Console.PrintMessage("Role "+obj.Role+" cannot be mapped for object "+obj.Label+"\n")
obj.removeProperty("Role")
def addToComponent(compobject,addobject,mod=None):
'''addToComponent(compobject,addobject,mod): adds addobject
to the given component. Default is in "Additions", "Objects" or
"Components", the first one that exists in the component. Mod
can be set to one of those attributes ("Objects", Base", etc...)
to override the default.'''
import Draft
if compobject == addobject: return
# first check zis already there
@@ -167,7 +145,11 @@ class Component:
self.Type = "Component"
def setProperties(self,obj):
"Sets the needed properties of this object"
ArchIFC.setProperties(obj)
pl = obj.PropertiesList
if not "Base" in pl:
obj.addProperty("App::PropertyLink","Base","Component",QT_TRANSLATE_NOOP("App::Property","The base object this component is built upon"))
@@ -189,29 +171,12 @@ class Component:
obj.Material = obj.BaseMaterial
obj.removeProperty("BaseMaterial")
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" BaseMaterial property to Material\n")
if not "IfcRole" in pl:
obj.addProperty("App::PropertyEnumeration","IfcRole","Component",QT_TRANSLATE_NOOP("App::Property","The role of this object"))
obj.IfcRole = IfcRoles
if "Role" in pl:
r = obj.Role
obj.removeProperty("Role")
if r in IfcRoles:
obj.IfcRole = r
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" Role property to IfcRole\n")
if "IfcType" in pl: # for future backwards compatibility
r = obj.IfcType
obj.removeProperty("IfcType")
if r in IfcRoles:
obj.IfcRole = r
FreeCAD.Console.PrintMessage("Downgrading "+obj.Label+" IfcType property to IfcRole\n")
if not "MoveBase" in pl:
obj.addProperty("App::PropertyBool","MoveBase","Component",QT_TRANSLATE_NOOP("App::Property","Specifies if moving this object moves its base instead"))
obj.MoveBase = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("MoveBase",False)
if not "MoveWithHost" in pl:
obj.addProperty("App::PropertyBool","MoveWithHost","Component",QT_TRANSLATE_NOOP("App::Property","Specifies if this object must move together when its host is moved"))
obj.MoveWithHost = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("MoveWithHost",False)
if not "IfcProperties" in pl:
obj.addProperty("App::PropertyMap","IfcProperties","Component",QT_TRANSLATE_NOOP("App::Property","Stores IFC properties"))
if not "VerticalArea" in pl:
obj.addProperty("App::PropertyArea","VerticalArea","Component",QT_TRANSLATE_NOOP("App::Property","The area of all vertical faces of this object"))
obj.setEditorMode("VerticalArea",1)
@@ -225,6 +190,7 @@ class Component:
obj.addProperty("App::PropertyLink","HiRes","Component",QT_TRANSLATE_NOOP("App::Property","An optional higher-resolution mesh or shape for this object"))
if not "Axis" in pl:
obj.addProperty("App::PropertyLink","Axis","Component",QT_TRANSLATE_NOOP("App::Property","An optional axis or axis system on which this object should be duplicated"))
self.Subvolume = None
#self.MoveWithHost = False
self.Type = "Component"
@@ -260,6 +226,7 @@ class Component:
self.oldPlacement = FreeCAD.Placement(obj.Placement)
def onChanged(self,obj,prop):
ArchIFC.onChanged(obj, prop)
if prop == "Placement":

View File

@@ -277,7 +277,7 @@ class _Equipment(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
obj.Proxy = self
self.setProperties(obj)
obj.IfcRole = "Furniture"
obj.IfcType = "Furniture"
def setProperties(self,obj):

View File

@@ -130,7 +130,7 @@ class _Floor:
obj.Proxy = self
self.Object = obj
_Floor.setProperties(self,obj)
self.IfcRole = "Building Storey"
self.IfcType = "Building Storey"
def setProperties(self,obj):
@@ -142,10 +142,10 @@ class _Floor:
if not hasattr(obj,"Placement"):
# obj can be a Part Feature and already has a placement
obj.addProperty("App::PropertyPlacement","Placement","Base",QT_TRANSLATE_NOOP("App::Property","The placement of this object"))
if not "IfcRole" in pl:
obj.addProperty("App::PropertyEnumeration","IfcRole","Component",QT_TRANSLATE_NOOP("App::Property","The role of this object"))
import ArchComponent
obj.IfcRole = ArchComponent.IfcRoles
if not "IfcType" in pl:
obj.addProperty("App::PropertyEnumeration","IfcType","Component",QT_TRANSLATE_NOOP("App::Property","The type of this object"))
import ArchIFC
obj.IfcType = ArchIFC.IfcTypes
self.Type = "Floor"
def onDocumentRestored(self,obj):

View File

@@ -106,7 +106,7 @@ class _Frame(ArchComponent.Component):
def __init__(self,obj):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Railing"
obj.IfcType = "Railing"
def setProperties(self,obj):

View File

@@ -1,39 +1,69 @@
import FreeCAD, os, json
"This modules sets up and manages the IFC-related properties, types and attributes of Arch/BIM objects"
if FreeCAD.GuiUp:
from PySide.QtCore import QT_TRANSLATE_NOOP
import ArchIFCSchema
IfcTypes = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in ArchIFCSchema.IfcProducts.keys()]
def setProperties(obj):
"Checks and sets all the needed IFC-related properties"
if not "IfcType" in obj.PropertiesList:
obj.addProperty("App::PropertyEnumeration","IfcType","IFC",QT_TRANSLATE_NOOP("App::Property","The type of this object"))
obj.IfcType = IfcTypes
if not "IfcData" in obj.PropertiesList:
obj.addProperty("App::PropertyMap","IfcData","Component",QT_TRANSLATE_NOOP("App::Property","IFC data"))
obj.addProperty("App::PropertyMap","IfcData","IFC",QT_TRANSLATE_NOOP("App::Property","IFC data"))
if not "IfcProperties" in obj.PropertiesList:
obj.addProperty("App::PropertyMap","IfcProperties","IFC",QT_TRANSLATE_NOOP("App::Property","IFC properties of this object"))
migrateDeprecatedAttributes(obj)
def onChanged(obj, prop):
if prop == "IfcRole":
"Called by Arch object's OnChanged method"
if prop == "IfcType":
setupIfcAttributes(obj)
if obj.getGroupOfProperty(prop) == "IFC Attributes":
setObjIfcAttributeValue(obj, prop, obj.getPropertyByName(prop))
def getIfcProduct(IfcRole):
import ArchIFCSchema
name = "Ifc" + IfcRole.replace(" ", "")
def getIfcProduct(IfcType):
"Returns an IFC product name from an obj.IfcType"
name = "Ifc" + IfcType.replace(" ", "")
if name in ArchIFCSchema.IfcProducts:
return ArchIFCSchema.IfcProducts[name]
def getIfcProductAttribute(ifcProduct, name):
"Returns the attributes of a given product"
for attribute in ifcProduct["attributes"]:
if attribute["name"].replace(' ', '') == name:
return attribute
return None
def setupIfcAttributes(obj):
ifcProduct = getIfcProduct(obj.IfcRole)
"Sets the necessary IFC attribute properties for an object"
ifcProduct = getIfcProduct(obj.IfcType)
if ifcProduct is None:
return
purgeUnusedIfcAttributesFromPropertiesList(ifcProduct, obj)
addIfcProductAttributesToObj(ifcProduct, obj)
def addIfcProductAttributesToObj(ifcProduct, obj):
"Adds the necessary attribute properties to an object"
for attribute in ifcProduct["attributes"]:
if attribute["name"] in obj.PropertiesList \
or attribute["name"] == "RefLatitude" \
@@ -43,6 +73,9 @@ def addIfcProductAttributesToObj(ifcProduct, obj):
addIfcAttributeValueExpressions(obj, attribute)
def addIfcProductAttribute(obj, attribute):
"Adds a given attribute property"
IfcData = obj.IfcData
if "attributes" not in IfcData:
IfcData["attributes"] = "{}"
@@ -59,6 +92,9 @@ def addIfcProductAttribute(obj, attribute):
obj.addProperty(propertyType, attribute["name"], "IFC Attributes", QT_TRANSLATE_NOOP("App::Property", "Description of IFC attributes are not yet implemented"))
def addIfcAttributeValueExpressions(obj, attribute):
"Binds the given attribute properties with expressions"
if obj.getGroupOfProperty(attribute["name"]) != "Ifc Attributes":
return
if attribute["name"] == "OverallWidth":
@@ -87,6 +123,9 @@ def addIfcAttributeValueExpressions(obj, attribute):
obj.setExpression("RefElevation", "Elevation.Value")
def setObjIfcAttributeValue(obj, attributeName, value):
"Sets the value of a given attribute property"
IfcData = obj.IfcData
IfcAttributes = json.loads(IfcData["attributes"])
if isinstance(value, FreeCAD.Units.Quantity):
@@ -96,6 +135,9 @@ def setObjIfcAttributeValue(obj, attributeName, value):
obj.IfcData = IfcData
def purgeUnusedIfcAttributesFromPropertiesList(ifcProduct, obj):
"Removes unused attribute properties"
for property in obj.PropertiesList:
if obj.getGroupOfProperty(property) != "IFC Attributes":
continue
@@ -104,7 +146,23 @@ def purgeUnusedIfcAttributesFromPropertiesList(ifcProduct, obj):
obj.removeProperty(property)
def migrateDeprecatedAttributes(obj):
# FreeCAD <= 0.17 stored IFC data in IfcAttributes
if hasattr(obj, "IfcAttributes"):
"Fixes obsolete properties"
if "Role" in obj.PropertiesList:
r = obj.Role
obj.removeProperty("Role")
if r in IfcTypes:
obj.IfcType = r
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" Role property to IfcType\n")
if "IfcRole" in obj.PropertiesList:
r = obj.IfcRole
obj.removeProperty("IfcRole")
if r in IfcTypes:
obj.IfcType = r
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" IfcRole property to IfcType\n")
if "IfcAttributes"in obj.PropertiesList:
obj.IfcData = obj.IfcAttributes
obj.removeProperty("IfcAttributes")

View File

@@ -397,7 +397,7 @@ class _Panel(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Plate"
obj.IfcType = "Plate"
def setProperties(self,obj):

View File

@@ -185,7 +185,7 @@ class _ArchPipe(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Pipe Segment"
obj.IfcType = "Pipe Segment"
def setProperties(self,obj):
@@ -314,7 +314,7 @@ class _ArchPipeConnector(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Pipe Fitting"
obj.IfcType = "Pipe Fitting"
def setProperties(self,obj):

View File

@@ -90,7 +90,7 @@ class _PrecastBeam(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Beam"
obj.IfcType = "Beam"
def setProperties(self,obj):
@@ -209,7 +209,7 @@ class _PrecastIbeam(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Beam"
obj.IfcType = "Beam"
def setProperties(self,obj):
@@ -272,7 +272,7 @@ class _PrecastPillar(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Column"
obj.IfcType = "Column"
def setProperties(self,obj):
@@ -410,7 +410,7 @@ class _PrecastPanel(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Plate"
obj.IfcType = "Plate"
def setProperties(self,obj):
@@ -518,7 +518,7 @@ class _PrecastSlab(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Slab"
obj.IfcType = "Slab"
def setProperties(self,obj):
@@ -627,7 +627,7 @@ class _PrecastStairs(_Precast):
_Precast.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Stair"
obj.IfcType = "Stair"
def setProperties(self,obj):

View File

@@ -165,7 +165,7 @@ class _Rebar(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Reinforcing Bar"
obj.IfcType = "Reinforcing Bar"
def setProperties(self,obj):

View File

@@ -183,7 +183,7 @@ class _Roof(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Roof"
obj.IfcType = "Roof"
obj.Proxy = self
def setProperties(self,obj):

View File

@@ -164,21 +164,15 @@ class _ArchSchedule:
elif args[0].upper() == "!TYPE":
if Draft.getType(o).upper() == args[1].upper():
ok = False
elif args[0].upper() == "ROLE":
if hasattr(o,"IfcRole"):
if o.IfcRole.upper() != args[1].upper():
ok = False
elif hasattr(o,"Role"):
if o.Role.upper() != args[1].upper():
elif args[0].upper() == "IFCTYPE":
if hasattr(o,"IfcType"):
if o.IfcType.upper() != args[1].upper():
ok = False
else:
ok = False
elif args[0].upper() == "!ROLE":
if hasattr(o,"Role"):
if o.IfcRole.upper() == args[1].upper():
ok = False
elif hasattr(o,"Role"):
if o.Role.upper() == args[1].upper():
elif args[0].upper() == "!IFCTYPE":
if hasattr(o,"IfcType"):
if o.IfcType.upper() == args[1].upper():
ok = False
if ok:
nobjs.append(o)

View File

@@ -281,7 +281,7 @@ class _CommandSite:
siteobj = []
warning = False
for obj in sel :
if (Draft.getType(obj) == "Building") or (hasattr(obj,"IfcRole") and obj.IfcRole == "Building"):
if (Draft.getType(obj) == "Building") or (hasattr(obj,"IfcType") and obj.IfcType == "Building"):
siteobj.append(obj)
else :
if link == True :
@@ -321,10 +321,12 @@ class _Site(ArchFloor._Floor):
ArchFloor._Floor.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Site"
obj.IfcType = "Site"
def setProperties(self,obj):
ArchIFC.setProperties(obj)
pl = obj.PropertiesList
if not "Terrain" in pl:
obj.addProperty("App::PropertyLink","Terrain","Site",QT_TRANSLATE_NOOP("App::Property","The base terrain of this site"))
@@ -370,8 +372,6 @@ class _Site(ArchFloor._Floor):
obj.addProperty("App::PropertyBool","RemoveSplitter","Site",QT_TRANSLATE_NOOP("App::Property","Remove splitters from the resulting shape"))
if not "OriginOffset" in pl:
obj.addProperty("App::PropertyVector","OriginOffset","Site",QT_TRANSLATE_NOOP("App::Property","An optional offset between the model (0,0,0) origin and the point indicated by the geocoordinates"))
if not "IfcProperties" in pl:
obj.addProperty("App::PropertyMap","IfcProperties","Site",QT_TRANSLATE_NOOP("App::Property","Stores IFC properties"))
if not hasattr(obj,"Group"):
obj.addExtension("App::GroupExtensionPython", self)
self.Type = "Site"

View File

@@ -264,7 +264,7 @@ class _Space(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Space"
obj.IfcType = "Space"
def setProperties(self,obj):

View File

@@ -262,7 +262,7 @@ class _Stairs(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Stair"
obj.IfcType = "Stair"
def setProperties(self,obj):

View File

@@ -97,9 +97,9 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structur
# gets wrong
obj.Length = p.GetFloat("StructureLength",100)
if not height and not length:
obj.IfcRole = "Undefined"
obj.IfcType = "Undefined"
elif obj.Height > obj.Length:
obj.IfcRole = "Column"
obj.IfcType = "Column"
return obj
def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"):
@@ -486,7 +486,7 @@ class _Structure(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Beam"
obj.IfcType = "Beam"
def setProperties(self,obj):
@@ -596,10 +596,10 @@ class _Structure(ArchComponent.Component):
"""returns (shape,extrusion vector,placement) or None"""
if hasattr(obj,"IfcRole"):
role = obj.IfcRole
if hasattr(obj,"IfcType"):
IfcType = obj.IfcType
else:
role = obj.Role
IfcType = None
import Part,DraftGeomUtils
data = ArchComponent.Component.getExtrusionData(self,obj)
if data:
@@ -675,7 +675,7 @@ class _Structure(ArchComponent.Component):
baseface = Part.Face(w)
base,placement = self.rebase(baseface)
elif length and width and height:
if (length > height) and (role != "Slab"):
if (length > height) and (IfcType != "Slab"):
h2 = height/2 or 0.5
w2 = width/2 or 0.5
v1 = Vector(0,-w2,-h2)
@@ -704,7 +704,7 @@ class _Structure(ArchComponent.Component):
if not normal.Length:
normal = Vector(0,0,1)
extrusion = normal
if (length > height) and (role != "Slab"):
if (length > height) and (IfcType != "Slab"):
if length:
extrusion = normal.multiply(length)
else:
@@ -715,12 +715,10 @@ class _Structure(ArchComponent.Component):
def onChanged(self,obj,prop):
if hasattr(obj,"IfcRole"):
role = obj.IfcRole
elif hasattr(obj,"Role"):
role = obj.Role
if hasattr(obj,"IfcType"):
IfcType = obj.IfcType
else:
role = None
IfcType = None
self.hideSubobjects(obj,prop)
if prop in ["Shape","ResetNodes","NodesOffset"]:
# ResetNodes is not a property but it allows us to use this function to force reset the nodes
@@ -729,7 +727,7 @@ class _Structure(ArchComponent.Component):
if extdata and not isinstance(extdata[0],list):
nodes = extdata[0]
nodes.Placement = nodes.Placement.multiply(extdata[2])
if role not in ["Slab"]:
if IfcType not in ["Slab"]:
if obj.Tool:
nodes = obj.Tool.Shape
elif extdata[1].Length > 0:
@@ -832,13 +830,13 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
self.lineset.coordIndex.setValues(0,len(p)+2,range(len(p)+1)+[-1])
self.faceset.coordIndex.setValues(0,len(p)+1,range(len(p))+[-1])
elif prop in ["Role","IfcRole"]:
elif prop in ["IfcType"]:
if hasattr(obj.ViewObject,"NodeType"):
if hasattr(obj,"IfcRole"):
role = obj.IfcRole
if hasattr(obj,"IfcType"):
IfcType = obj.IfcType
else:
role = obj.Role
if role == "Slab":
IfcType = None
if IfcType == "Slab":
obj.ViewObject.NodeType = "Area"
else:
obj.ViewObject.NodeType = "Linear"

View File

@@ -519,7 +519,7 @@ class _Wall(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Wall"
obj.IfcType = "Wall"
def setProperties(self,obj):

View File

@@ -566,7 +566,7 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None
obj.Offset = o1
obj.Placement = FreeCAD.Placement() # unable to find where this bug comes from...
if "door" in windowtype:
obj.IfcRole = "Door"
obj.IfcType = "Door"
obj.Label = translate("Arch","Door")
FreeCAD.ActiveDocument.recompute()
return obj
@@ -917,7 +917,7 @@ class _Window(ArchComponent.Component):
ArchComponent.Component.__init__(self,obj)
self.setProperties(obj)
obj.IfcRole = "Window"
obj.IfcType = "Window"
obj.MoveWithHost = True
def setProperties(self,obj):

View File

@@ -823,23 +823,13 @@ def insert(filename,docname,skip=[],only=[],root=None):
except ReferenceError:
pass
# setting IFC role
# setting IFC type
try:
if hasattr(obj,"IfcRole"):
obj.IfcRole = ''.join(map(lambda x: x if x.islower() else " "+x, ptype[3:]))[1:]
else:
# pre-0.18 objects, only support a small subset of types
r = ptype[3:]
tr = dict((v,k) for k, v in translationtable.items())
if r in tr.keys():
r = tr[r]
# remove the "StandardCase"
if "StandardCase" in r:
r = r[:-12]
obj.Role = r
if hasattr(obj,"IfcType"):
obj.IfcType = ''.join(map(lambda x: x if x.islower() else " "+x, ptype[3:]))[1:]
except:
print("Unable to give IFC role ",ptype," to object ",obj.Label)
print("Unable to give IFC type ",ptype," to object ",obj.Label)
# setting uid
@@ -878,20 +868,10 @@ def insert(filename,docname,skip=[],only=[],root=None):
if product.Description:
obj.Description = product.Description
try:
if hasattr(obj,"IfcRole"):
obj.IfcRole = ''.join(map(lambda x: x if x.islower() else " "+x, ptype[3:]))[1:]
else:
# pre-0.18 objects, only support a small subset of types
r = ptype[3:]
tr = dict((v,k) for k, v in translationtable.items())
if r in tr.keys():
r = tr[r]
# remove the "StandardCase"
if "StandardCase" in r:
r = r[:-12]
obj.Role = r
if hasattr(obj,"IfcType"):
obj.IfcType = ''.join(map(lambda x: x if x.islower() else " "+x, ptype[3:]))[1:]
except:
print("Unable to give IFC role ",ptype," to object ",obj.Label)
print("Unable to give IFC type ",ptype," to object ",obj.Label)
if hasattr(obj,"IfcData"):
a = obj.IfcData
a["IfcUID"] = str(guid)
@@ -1679,7 +1659,7 @@ def export(exportList,filename):
d["IfcUID"] = uid
obj.IfcData = d
ifctype = getIfcRoleFromObj(obj)
ifctype = getIfcTypeFromObj(obj)
if ifctype == "IfcGroup":
groups[obj.Name] = [o.Name for o in obj.Group]
@@ -2079,7 +2059,7 @@ def export(exportList,filename):
# buildingParts can be exported as any "normal" IFC type. In that case, gather their elements first
for bp in Draft.getObjectsOfType(objectslist,"BuildingPart"):
if bp.IfcRole not in ["Site","Building","Building Storey","Space","Undefined"]:
if bp.IfcType not in ["Site","Building","Building Storey","Space","Undefined"]:
if bp.Name in products:
subs = []
for c in bp.Group:
@@ -2092,7 +2072,7 @@ def export(exportList,filename):
# floors/buildingparts
for floor in Draft.getObjectsOfType(objectslist,"Floor")+Draft.getObjectsOfType(objectslist,"BuildingPart"):
if (Draft.getType(floor) == "Floor") or (hasattr(floor,"IfcRole") and floor.IfcRole == "Building Storey"):
if (Draft.getType(floor) == "Floor") or (hasattr(floor,"IfcType") and floor.IfcType == "Building Storey"):
objs = Draft.getGroupContents(floor,walls=True,addgroups=True)
objs = Arch.pruneIncluded(objs)
children = []
@@ -2111,7 +2091,7 @@ def export(exportList,filename):
# buildings
for building in Draft.getObjectsOfType(objectslist,"Building")+Draft.getObjectsOfType(objectslist,"BuildingPart"):
if (Draft.getType(building) == "Building") or (hasattr(building,"IfcRole") and building.IfcRole == "Building"):
if (Draft.getType(building) == "Building") or (hasattr(building,"IfcType") and building.IfcType == "Building"):
objs = Draft.getGroupContents(building,walls=True,addgroups=True)
objs = Arch.pruneIncluded(objs)
children = []
@@ -2168,7 +2148,7 @@ def export(exportList,filename):
if not(Draft.getType(FreeCAD.ActiveDocument.getObject(k)) in ["Site","Building","Floor","BuildingPart"]):
untreated.append(v)
elif Draft.getType(FreeCAD.ActiveDocument.getObject(k)) == "BuildingPart":
if not(FreeCAD.ActiveDocument.getObject(k).IfcRole in ["Building","Building Storey","Site","Space","Undefined"]):
if not(FreeCAD.ActiveDocument.getObject(k).IfcType in ["Building","Building Storey","Site","Space","Undefined"]):
untreated.append(v)
if untreated:
if not defaulthost:
@@ -2368,14 +2348,12 @@ def export(exportList,filename):
del ifcbin
def getIfcRoleFromObj(obj):
def getIfcTypeFromObj(obj):
if (Draft.getType(obj) == "BuildingPart") and hasattr(obj,"IfcRole") and (obj.IfcRole == "Undefined"):
if (Draft.getType(obj) == "BuildingPart") and hasattr(obj,"IfcType") and (obj.IfcType == "Undefined"):
ifctype = "IfcBuildingStorey" # export BuildingParts as Storeys if their type wasn't explicitly set
elif hasattr(obj,"IfcRole"):
ifctype = obj.IfcRole.replace(" ","")
elif hasattr(obj,"Role"):
ifctype = obj.Role.replace(" ","")
elif hasattr(obj,"IfcType"):
ifctype = obj.IfcType.replace(" ","")
else:
ifctype = Draft.getType(obj)
@@ -2389,16 +2367,16 @@ def getIfcRoleFromObj(obj):
def exportIFC2X3Attributes(obj, kwargs):
role = getIfcRoleFromObj(obj)
if role in ["IfcSlab", "IfcFooting", "IfcRoof"]:
ifctype = getIfcTypeFromObj(obj)
if ifctype in ["IfcSlab", "IfcFooting", "IfcRoof"]:
kwargs.update({"PredefinedType": "NOTDEFINED"})
elif role == "IfcBuilding":
elif ifctype == "IfcBuilding":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcBuildingStorey":
elif ifctype == "IfcBuildingStorey":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcBuildingElementProxy":
elif ifctype == "IfcBuildingElementProxy":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcSpace":
elif ifctype == "IfcSpace":
internal = "NOTDEFINED"
if hasattr(obj,"Internal"):
if obj.Internal:
@@ -2408,10 +2386,10 @@ def exportIFC2X3Attributes(obj, kwargs):
kwargs.update({"CompositionType": "ELEMENT",
"InteriorOrExteriorSpace": internal,
"ElevationWithFlooring": obj.Shape.BoundBox.ZMin/1000.0})
elif role == "IfcReinforcingBar":
elif ifctype == "IfcReinforcingBar":
kwargs.update({"NominalDiameter": obj.Diameter.Value,
"BarLength": obj.Length.Value})
elif role == "IfcBuildingStorey":
elif ifctype == "IfcBuildingStorey":
kwargs.update({"Elevation": obj.Placement.Base.z/1000.0})
return kwargs