Skip to content

Commit 66e07c2

Browse files
committed
Include buildingSMART psets in IfcFM Basic preset
1 parent 2b067b9 commit 66e07c2

1 file changed

Lines changed: 29 additions & 60 deletions

File tree

src/ifcfm/ifcfm/basic.py

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
import ifcopenshell.util.classification
2525

2626

27-
def get_actors(ifc_file):
28-
return ifc_file.by_type("IfcActor")
29-
30-
3127
def get_facilities(ifc_file):
3228
return ifc_file.by_type("IfcBuilding")
3329

@@ -63,23 +59,6 @@ def get_systems(ifc_file):
6359
return ifc_file.by_type("IfcSystem")
6460

6561

66-
def get_actor_data(ifc_file, element):
67-
return {
68-
"key": element.TheActor.Name,
69-
"Name": element.TheActor.Name,
70-
"Category": get_classification(element),
71-
"Email": get_actor_address(element, "ElectronicMailAddresses"),
72-
"Phone": get_actor_address(element, "TelephoneNumbers"),
73-
"CompanyURL": get_actor_address(element, "WWWHomePageURL"),
74-
"Department": get_actor_address(element, "InternalLocation"),
75-
"Address": get_actor_address(element, "AddressLines"),
76-
"Town": get_actor_address(element, "Town"),
77-
"Region": get_actor_address(element, "Region"),
78-
"PostalCode": get_actor_address(element, "PostalCode"),
79-
"Country": get_actor_address(element, "Country"),
80-
}
81-
82-
8362
def get_facility_data(ifc_file, element):
8463
return {
8564
"key": element.Name,
@@ -95,7 +74,6 @@ def get_facility_data(ifc_file, element):
9574
"ModelBuildingID": element.GlobalId,
9675
"LinearUnits": "millimeters",
9776
"AreaUnits": "square meters",
98-
"AreaMeasurement": "BIM Software",
9977
"Phase": ifc_file.by_type("IfcProject")[0].Phase,
10078
}
10179

@@ -145,6 +123,7 @@ def get_zone_data(ifc_file, element):
145123

146124

147125
def get_element_type_data(ifc_file, element):
126+
psets = ifcopenshell.util.element.get_psets(element)
148127
return {
149128
"key": element.Name,
150129
"Name": element.Name,
@@ -156,6 +135,11 @@ def get_element_type_data(ifc_file, element):
156135
"ModelObject": "{}[{}]".format(element.is_a(), ifcopenshell.util.element.get_predefined_type(element)),
157136
"ModelID": element.GlobalId,
158137
"ModelTag": element.Tag,
138+
"Manufacturer": get_property(psets, "Pset_ManufacturerTypeInformation", "Manufacturer"),
139+
"ModelReference": get_property(psets, "Pset_ManufacturerTypeInformation", "ModelReference"),
140+
"ModelLabel": get_property(psets, "Pset_ManufacturerTypeInformation", "ModelLabel"),
141+
"PointOfContact": get_property(psets, "Pset_Warranty", "PointOfContact"),
142+
"WarrantyPeriod": get_property(psets, "Pset_Warranty", "WarrantyPeriod"),
159143
}
160144

161145

@@ -164,6 +148,7 @@ def get_element_data(ifc_file, element):
164148
space_name = space.Name if space.is_a("IfcSpace") else None
165149
systems = ifcopenshell.util.system.get_element_systems(element)
166150
system = systems[0].Name if systems else None
151+
psets = ifcopenshell.util.element.get_psets(element)
167152
return {
168153
"key": element.Name,
169154
"Name": element.Name,
@@ -176,6 +161,13 @@ def get_element_data(ifc_file, element):
176161
"ModelObject": "{}[{}]".format(element.is_a(), ifcopenshell.util.element.get_predefined_type(element)),
177162
"ModelID": element.GlobalId,
178163
"ModelTag": element.Tag,
164+
"SerialNumber": get_property(psets, "Pset_ManufacturerOccurrence", "SerialNumber"),
165+
"BarCode": get_property(psets, "Pset_ManufacturerOccurrence", "BarCode"),
166+
"BatchReference": get_property(psets, "Pset_ManufacturerOccurrence", "BatchReference"),
167+
"TagNumber": get_property(psets, "Pset_ConstructionOccurrence", "TagNumber"),
168+
"AssetIdentifier": get_property(psets, "Pset_ConstructionOccurrence", "AssetIdentifier"),
169+
"InstallationDate": get_property(psets, "Pset_ConstructionOccurrence", "InstallationDate"),
170+
"WarrantyStartDate": get_property(psets, "Pset_Warranty", "WarrantyStartDate"),
179171
}
180172

181173

@@ -228,21 +220,6 @@ def get_classification(element):
228220
return "{}:{}".format(references[0].ItemReference, references[0].Name)
229221

230222

231-
def get_actor_address(element, name):
232-
actors = []
233-
if element.TheActor.is_a("IfcOrganization") or element.TheActor.is_a("IfcPerson"):
234-
actors = [element.TheActor]
235-
elif element.TheActor.is_a("IfcPersonAndOrganization"):
236-
actors = [element.TheActor.TheOrganization, element.TheActor.ThePerson]
237-
for actor in actors:
238-
for address in actor.Addresses or []:
239-
if hasattr(address, name) and getattr(address, name, None):
240-
result = getattr(address, name)
241-
if isinstance(result, tuple):
242-
return result[0]
243-
return result
244-
245-
246223
def get_property(psets, pset_name, prop_name, decimals=None):
247224
if pset_name in psets:
248225
result = psets[pset_name].get(prop_name, None)
@@ -252,7 +229,6 @@ def get_property(psets, pset_name, prop_name, decimals=None):
252229

253230

254231
get_category_elements = {
255-
"Actors": get_actors,
256232
"Facilities": get_facilities,
257233
"Storeys": get_storeys,
258234
"Spaces": get_spaces,
@@ -263,7 +239,6 @@ def get_property(psets, pset_name, prop_name, decimals=None):
263239
}
264240

265241
get_element_data = {
266-
"Actors": get_actor_data,
267242
"Facilities": get_facility_data,
268243
"Storeys": get_storey_data,
269244
"Spaces": get_space_data,
@@ -285,23 +260,6 @@ def get_property(psets, pset_name, prop_name, decimals=None):
285260
"b": "000000", # Not in scope
286261
},
287262
"categories": {
288-
"Actors": {
289-
"headers": [
290-
"Name",
291-
"Category",
292-
"Email",
293-
"Phone",
294-
"CompanyURL",
295-
"Department",
296-
"Address",
297-
"Town",
298-
"Region",
299-
"PostalCode",
300-
"Country",
301-
],
302-
"colours": "ppssssssss",
303-
"sort": [{"name": "Name", "order": "ASC"}],
304-
},
305263
"Facilities": {
306264
"headers": [
307265
"Name",
@@ -316,10 +274,9 @@ def get_property(psets, pset_name, prop_name, decimals=None):
316274
"ModelBuildingID",
317275
"LinearUnits",
318276
"AreaUnits",
319-
"AreaMeasurement",
320277
"Phase",
321278
],
322-
"colours": "ppppreeeeessss",
279+
"colours": "ppppreeeeesss",
323280
"sort": [{"name": "Name", "order": "ASC"}],
324281
},
325282
"Storeys": {
@@ -368,8 +325,13 @@ def get_property(psets, pset_name, prop_name, decimals=None):
368325
"ModelObject",
369326
"ModelID",
370327
"ModelTag",
328+
"Manufacturer",
329+
"ModelReference",
330+
"ModelLabel",
331+
"PointOfContact",
332+
"WarrantyPeriod",
371333
],
372-
"colours": "pppreeeee",
334+
"colours": "pppreeeeesssss",
373335
"sort": [{"name": "ModelObject", "order": "ASC"}, {"name": "Name", "order": "ASC"}],
374336
},
375337
"Elements": {
@@ -384,8 +346,15 @@ def get_property(psets, pset_name, prop_name, decimals=None):
384346
"ModelObject",
385347
"ModelID",
386348
"ModelTag",
349+
"SerialNumber",
350+
"BarCode",
351+
"BatchReference",
352+
"TagNumber",
353+
"AssetIdentifier",
354+
"InstallationDate",
355+
"WarrantyStartDate",
387356
],
388-
"colours": "prrrreeeee",
357+
"colours": "prrrreeeeesssssss",
389358
"sort": [{"name": "TypeName", "order": "ASC"}, {"name": "Name", "order": "ASC"}],
390359
},
391360
"Systems": {

0 commit comments

Comments
 (0)