If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)

ifc, get the data typ of a property value with ifcopenshell

edited March 2021 in General

import ifcopenshell.util.element
print(ifcopenshell.util.element.get_psets(myslab))

returns a dictionary which looks like this ...
{'AllplanAttributes': {'Umbaukategorie': 'Neubau', 'Gewerk': 'Betonarbeiten', 'Bezeichnung': 'Plattenfundament', 'Material Statik': 'NPK-C_WDB', 'Erdreich': 'yes', 'Festigkeitsklasse Beton': 'Ph_41', 'Betonzusätze': 'Ph_41', 'Bautaktung': 'Ph_51', 'Oberfächenbehandlung': 'Ph_41', 'Allright_Bauteil_ID': '1305PFu0000000010', 'Einheit': 'm³'}, 'GI^U': {'Tragendes Bauteil': True, 'Aussenbauteil': True, 'Geschoss': '01.UG_FBOK', 'Typenname': 'C1_BP_Ortbeton_XXXX', 'Gebäude': 'Spiserstrasse', 'Bewehrungsgehalt': '120', 'Schalungstyp': '2', 'Teilprojekt': 'Leutwyler', 'Dichtigkeitsklasse': 'DK2', 'Lastanforderungen': '5.0 kN/m2', 'eBKP-H': 'C 1.5', 'BKP': '211.5'}, 'GU_Material': {'Material': 'Ortbeton'}, 'GU_Mengen': {'Breite': 0.0, 'Dicke': 16.3827, 'Höhe': 0.35, 'Fläche': 311.1078, 'Länge': 18.99, 'Volumen': 108.8877}}

In the dictionary the property values are Python class types String, Int, Float, Bool. Is there some method do get the IFC type of property as IfcText or IfcReal or whatever it was in the ifc file directly (similar to the get_psets) without do all the property parsing myself once again?

BTW: AFAIR there have been versions of get_psets which did return the value type too?

cheers bernd

Comments

  • Unfortunately get_psets does not do this. ifcopenshell.api.pset.data does do this.

    If you are navigating the schema, you may find ifcopenshell.util.attribute useful for checking data types.

  • great I will have a look at them.

    The meantime as a workaround I made a hard coded mapping from ifc datatype to Python datatype and did implement a check for the Python data type by the use of isinstance() which was very fast to implement ... Means the user inputs a test for "IfcText" but the code does check for isinstance(value, str).

  • edited March 2021

    BTW: ifcopenshell on FreeCAD binary is outdated. The methodeds mentioned here are not included. I will try to get an update organised.

  • Hi @bernd,
    i am trying now to prove the ifc-Datatyps. Did you try it with ifcopenshell.api.pset.data?
    From what I found, it is possible to in the module "ifcopenshell.api.run" with the parameter "primary_measure_type" to give the ifc_datatyp.
    I do not want to give this information, but I want to get it.

  • Andre I've just implemented a new feature where you can specify a verbose flag to ifcopenshell.util.element.get_pset or get_psets. If enabled, it provides the property ID and class, which lets you do more complex analysis such as units or data types.

    _Andre_
  • @Moult, thank you for the insights. Based on what I found in the Module Contents (https://blenderbim.org/docs-python/autoapi/ifcopenshell/util/element/index.html), it appears that the documentation does not explicitly mention the data types of the properties in an IFC element. Could you confirm if this is the latest documentation available? If there are examples provided elsewhere, I would greatly appreciate it. Thank you.

Sign In or Register to comment.