Last active
January 29, 2020 20:32
-
-
Save pavelgordon/d89a42703b818dbcc007df9e9dd6d7ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ifcopenshell | |
f = ifcopenshell.open("Stratumsedijk_AC17_08-04-2015.ifc") | |
windows = f.by_type("ifcWindow") | |
print(windows) | |
print(len(windows)) # when i have the zero in brakets after f.by_type _ i get the number of elements in brackets for the first element | |
# print(windows.is_a())# in this case this commands in working and shows that its ifcWindows. | |
# when i have no 0 in brakets, the command len gives the number of windows in the file . and command windows.is_a does not work | |
prop_dict = {} | |
for window in windows: | |
print('parsing object with id', window.id()) | |
propsets = [] | |
def process_pset(prop_def): | |
if prop_def is not None: | |
prop_set_name = prop_def.Name | |
props = {} | |
if prop_def.is_a("IfcElementQuantity"): | |
for q in prop_def.Quantities: | |
if q.is_a("IfcPhysicalSimpleQuantity"): | |
props[q.Name] = q[3] | |
elif prop_def.is_a("IfcPropertySet"): | |
for prop in prop_def.HasProperties: | |
if prop.is_a("IfcPropertySingleValue"): | |
props[prop.Name] = prop.NominalValue | |
else: | |
# Entity introduced in IFC4 | |
# prop_def.is_a("IfcPreDefinedPropertySet"): | |
for prop in range(4, len(prop_def)): | |
props[prop_def.attribute_name(prop)] = prop_def[prop] | |
if "IsExternal" in props: | |
print("\tIsExternal", props['IsExternal']) | |
if "LoadBearing" in props: | |
print("\tLoadBearing", props['LoadBearing']) | |
if "FireRating" in props: | |
print("\tFireRating", props['FireRating']) | |
return prop_set_name, props | |
try: | |
for is_def_by in window.IsDefinedBy: | |
if is_def_by.is_a("IfcRelDefinesByProperties"): | |
propsets.append(process_pset(is_def_by.RelatingPropertyDefinition)) | |
elif is_def_by.is_a("IfcRelDefinesByType"): | |
type_psets = is_def_by.RelatingType.HasPropertySets | |
if type_psets is None: | |
continue | |
for propset in type_psets: | |
propsets.append(process_pset(propset)) | |
except Exception as e: | |
import traceback | |
print("failed to load properties: {}".format(e)) | |
traceback.print_exc() | |
if len(propsets): | |
prop_dict[str(window)] = propsets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment