get all BuildingSmart smart properties for an object

edited June 2023 in General

BuildingSmart defines dozens of PSets and properties for a IfcDoor : https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcDoor.htm#6.1.3.16.5-Property-sets
Is it possible to get them by python in IfcOpenShell somehow to furter process them

Comments

  • Something like this? Just tested it on the Schependomlaan.ifc

    import ifcopenshell
    from blenderbim.bim.ifc import IfcStore
    
    ifc_file = ifcopenshell.open(IfcStore.path)
    products = ifc_file.by_type('IfcDoor')
    
    for ifcproduct in products:
        if ifcproduct.IsDefinedBy:        
            for ifcreldefinesbyproperties in ifcproduct.IsDefinedBy:
                if (ifcreldefinesbyproperties.is_a()) == 'IfcRelDefinesByProperties':
                    if ifcreldefinesbyproperties.RelatingPropertyDefinition.is_a() == 'IfcPropertySet':
                        for ifcproperty in (ifcreldefinesbyproperties.RelatingPropertyDefinition.HasProperties):
                            print (ifcproduct.Name, ifcreldefinesbyproperties.RelatingPropertyDefinition.Name, ifcproperty)
    

    Section of output:

    ...
    D1L AC_Pset_32_KD_berkvens_BA #978576=IfcPropertySingleValue('openingshoek 2d',$,IfcPlaneAngleMeasure(15.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978577=IfcPropertySingleValue('arcering kozijn',$,IfcLabel('000 Ddichte arcering (01)'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978578=IfcPropertySingleValue('arcering kozijnachtergrond',$,IfcLabel('Lege arcering (2)'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978579=IfcPropertySingleValue('pen contourlijn kozijn',$,IfcLabel('Standaardpen'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978580=IfcPropertySingleValue('pen acchergrondarcering',$,IfcLabel('Achtergrond wit - NIET WIJZIGEN'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978581=IfcPropertySingleValue('pen acchergrondarcering kozijn',$,IfcLabel('Standaardpen'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978582=IfcPropertySingleValue('pen acering deurzijde',$,IfcLabel('Achtergrond wit - NIET WIJZIGEN'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978583=IfcPropertySingleValue('pen arcering dorpelzijde',$,IfcLabel('Achtergrond wit - NIET WIJZIGEN'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978584=IfcPropertySingleValue('deurarcering',$,IfcLabel('310 naaldhout (01)'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978585=IfcPropertySingleValue('pen arcering deur',$,IfcLabel('Standaardpen'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978586=IfcPropertySingleValue('openingshoek 3d',$,IfcPlaneAngleMeasure(0.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978587=IfcPropertySingleValue('openingslijnen',$,IfcLabel('beiden'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978588=IfcPropertySingleValue('deurdorpel',$,IfcBoolean(.F.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978589=IfcPropertySingleValue('materiaal dorpel',$,IfcLabel('RAL 9005 '),$)
    D1L AC_Pset_32_KD_berkvens_BA #978590=IfcPropertySingleValue('bovenlichttype',$,IfcLabel('glas'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978591=IfcPropertySingleValue('materiaal bovenlicht glas',$,IfcLabel('Glas - blauw'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978592=IfcPropertySingleValue('materiaal bovenlicht paneel',$,IfcLabel('RAL 9010 '),$)
    D1L AC_Pset_32_KD_berkvens_BA #978593=IfcPropertySingleValue('neuslat links (scharnierzijde)',$,IfcBoolean(.F.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978594=IfcPropertySingleValue('neuslat rechts (scharnierzijde',$,IfcBoolean(.T.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978595=IfcPropertySingleValue('materiaal neuslatten',$,IfcLabel('Verf - wit'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978596=IfcPropertySingleValue('kruk en schild',$,IfcBoolean(.T.),$)
    D1L AC_Pset_32_KD_berkvens_BA #978597=IfcPropertySingleValue('materiaal kruk en schild',$,IfcLabel('Metaal - Roestvrijstaal'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978598=IfcPropertySingleValue('slottype',$,IfcLabel('loopslot'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978599=IfcPropertySingleValue('materiaal cilinder',$,IfcLabel('Metaal - Roestvrijstaal'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978600=IfcPropertySingleValue('materiaal deur',$,IfcLabel('RAL 9001'),$)
    D1L AC_Pset_32_KD_berkvens_BA #978601=IfcPropertySingleValue('materiaal kozijn',$,IfcLabel('RAL 9010 '),$)
    D1L AC_Pset_RenovationAndPhasing #978607=IfcPropertySingleValue('Renovation Status',$,IfcLabel('New'),$)
    D1L Pset_DoorCommon #978613=IfcPropertySingleValue('IsExternal',$,IfcBoolean(.F.),$)
    ...
    
  • another question in this regard. AFAIK BuildingSmart defines property names in different main world languarges. I could not find them on the page linked in the post before.

  • I would like to try similar in FreeCAD :D
    @bernd Any idea what is equivalent in FreeCAD

    from blenderbim.bim.ifc import IfcStore

    Thanks

  • edited June 2023

    No not all properties from a model like Schependomlaanbut but all properties BuildingSmart has defined for an IfcDoor in ifc schema 4x3. That is why I posted the link. I would like to have all possible BuildingSmart properties in a list.

    Coen
  • I FreeCAD I found this list https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Arch/Presets/pset_definitions.csv I do not know if similar exist in BlenderBIM or where does BlenderBIM gets its Property names from?

  • Following the psets for IFC4 but how do I get them for IFC version 4.3

    import ifcopenshell.util.pset
    from ifcopenshell import util
    pset_qto = util.pset.PsetQto("IFC4")
    all_psets = pset_qto.get_applicable_names("IfcDoor")
    
    for pset in all_psets:
        print(pset)
    
    
    >>> import ifcopenshell.util.pset
    >>> from ifcopenshell import util
    >>> pset_qto = util.pset.PsetQto("IFC4")
    >>> all_psets = pset_qto.get_applicable_names("IfcDoor")
    >>> 
    >>> for pset in all_psets:
    ...     print(pset)
    ... 
    Pset_EnvironmentalImpactIndicators
    Pset_EnvironmentalImpactValues
    Pset_DoorCommon
    Pset_DoorWindowGlazingType
    Qto_DoorBaseQuantities
    Pset_Condition
    Pset_ManufacturerOccurrence
    Pset_ManufacturerTypeInformation
    Pset_ServiceLife
    Pset_Warranty
    >>> 
    
    Coenpaullee
  • edited June 2023

    for IFC4x3 I get error key does not exist

    >>> util.pset.PsetQto("IFC4x3").get_applicable_names("IfcDoor")
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:\0_BHA_privat\progr\FreeCAD\FreeCAD_0.21.xxxxx\bin\lib\site-packages\ifcopenshell\util\pset.py", line 47, in __init__
        path = str(folder_path.joinpath("schema", self.templates_path[schema]))
    KeyError: 'IFC4x3'
    >>> 
    
  • Thanks Bernd, it works in FreeCAD also :D

    Coen
  • edited June 2023

    @bernd IFC4X3 pset support was added a few months ago. Note that you have to specify "IFC4X3" with a capital X, not lowercase.

    >>> ifcopenshell.util.pset.PsetQto("IFC4X3").get_applicable_names("IfcDoor")
    ['Pset_Condition', 'Pset_ConstructionAdministration', 'Pset_ConstructionOccurence', 'Pset_DoorCommon', 'Pset_DoorWindowGlazingType', 'Pset_ElementKinematics', 'Pset_EnvironmentalCondition', 'Pset_EnvironmentalImpactIndicators', 'Pset_EnvironmentalImpactValues', 'Pset_InstallationOccurrence', 'Pset_MaintenanceStrategy', 'Pset_MaintenanceTriggerCondition', 'Pset_MaintenanceTriggerDuration', 'Pset_MaintenanceTriggerPerformance', 'Pset_ManufacturerOccurrence', 'Pset_ManufacturerTypeInformation', 'Pset_ProcessCapacity', 'Pset_RepairOccurrence', 'Pset_Risk', 'Pset_ServiceLife', 'Pset_Tolerance', 'Pset_Uncertainty', 'Pset_Warranty', 'Qto_BodyGeometryValidation', 'Qto_DoorBaseQuantities']
    

    Ping @yorik you might want to delete https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Arch/Presets/pset_definitions.csv and use the IfcOpenShell util instead that way it is always up to date.

    paullee
  • @Moult Seems not working in FreeCAD ?

    import ifcopenshell.util.pset

    ifcopenshell.util.pset.PsetQto("IFC4X3")

    Traceback (most recent call last):
    File "", line 1, in
    File "/home/paullee/Downloads/FreeCAD_weekly-builds-33071-2023-05-04-conda-Linux-x86_64-py311/squashfs-root/usr/lib/python3.11/site-packages/ifcopenshell/util/pset.py", line 47, in init
    path = str(folder_path.joinpath("schema", self.templates_path[schema]))
    ~~~~~~~^^^^^^^^
    KeyError: 'IFC4X3'

    ifcopenshell.util.pset.PsetQto("IFC4X3").get_applicable_names("IfcDoor")

    Traceback (most recent call last):
    File "", line 1, in
    File "/home/paullee/Downloads/FreeCAD_weekly-builds-33071-2023-05-04-conda-Linux-x86_64-py311/squashfs-root/usr/lib/python3.11/site-packages/ifcopenshell/util/pset.py", line 47, in init
    path = str(folder_path.joinpath("schema", self.templates_path[schema]))
    ~~~~~~~^^^^^^^^
    KeyError: 'IFC4X3

  • @paullee IFC4X3 should be in the templates path: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/util/pset.py#L42

    If it doesn't, that means FreeCAD perhaps ships an outdated version of IfcOpenShell. That functionality was added a few months ago. I'm not sure how FreeCAD bundles IfcOpenShell.

    paullee
  • edited June 2023

    @Moult Thanks, I am trying to check whilst I see your remarks above, not sure the correct way to do it though at the moment. referring to FreeCAD wiki https://wiki.freecad.org/IfcOpenShell

    @yorik Could you comment please?

    Thanks :)

    ifcopenshell.ifcopenshell.version

    'v0.7.0-07ee62eb9'

    It is python 3.10

    ifcopenshell.path

    ['/home/paullee/.local/lib/python3.10/site-packages/ifcopenshell']

  • edited June 2023

    07ee62eb9 is Jan 18. So yes, it is outdated. From the path it seems as though your IfcOpenShell is on your system (i.e. not tied to FreeCAD). You can upgrade using these instructions https://blenderbim.org/docs-python/ifcopenshell-python/installation.html#pre-built-packages

    It seems as though the FreeCAD Wiki can (should?) point to the install docs here instead https://blenderbim.org/docs-python/ifcopenshell-python/installation.html which is kept up to date and includes a few more methods of installation.

    paullee
  • IfcOpenShell is bundled with the stable installers of FreeCAD. Basically the latest available version at this point. But indeed after several months users find themselves with a rather old version...

    This wasn't really a problem until now, because the standard IFC import/exporter bundled with FreeCAD/Arch uses pretty much standard features, but now with NativeIFC we use extreme advanced features, that's how bold we are ?...

    Maybe it's time to change this, ex. download IfcOpenShell at run time? Since FreeCAD 0.21 is about to be released I think it's best not to change that just now, but after that it might be interesting to look at it.
    Indeed the blenderbim install page should be mentioned on the wiki.. will do that now

    paullee
  • @yorik I am not sure the version outcome I reported is that bundled with FreeCAD AppImage I use - as FC seems use 3.11, but ifcopenshell report 3.10.

    I have Fedora version installed also so not sure if it confused Appimage.

    I may test again - or you are sure it is the same versiom (outdated as Moult pointed out ?

  • OK, @yorik it turns out an earlier AppImage version run python 11 (FreeCAD_weekly-builds-33071-2023-05-04-conda-Linux-x86_64-py311); later all python 310. Why?

    Anyway, it does not run the 'system ifconpenshell' but the 'bundled one with AppImage, but it only return -

    ifcopenshell.version

    '0.7.0'

    ifcopenshell.path

    ['/home/paullee/Downloads/FreeCAD_weekly-builds-33071-2023-05-04-conda-Linux-x86_64-py311/squashfs-root/usr/lib/python3.11/site-packages/ifcopenshell']

    @Moult Any further command to return anything more than '0.7.0' ? (Though this version also returns KeyError : 'IFC4X3')

  • 'pip list' on my Fedora 36 command prompt return
    'ifcopenshell 0.7.0.230218'

  • Definitely you need an ifcopenshell compiled with the same python version of FreeCAD. Not sure why one appimage had py11 and the others not... maybe there was some bug with py11 at that time. Also i'm not sure if an appimage can use system python packages... if not, that's annoying, but there might still pe a way to place manually the ifcopenshell folder in one of the python sys.path

  • edited June 2023

    No worry about python version :)

    Just tested the latest AppImage released yesterday - have 'pip uninstall' the 'system' ifcopenshell, and in FC python console it import the bundled ifcopenshell - But it sill have the KeyError : 'IFC4X3'.

    Need to wait until FC bundle with latest ifcopenshell :D

  • what about installing a blenderbim package in one of the sys.path folders ?

    paullee
  • edited June 2023

    Now I am not sure ... @Moult
    1. I download the pre-built package from https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-310-v0.7.0-476ab50-linux64.zip
    2. Then, put in the /home/paullee/.local/lib/python3.10
    3. Import in FreeCAD console seems would load this version (rather than FC bundled one)
    4. Everything is fine but still KeyError :D

    "Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:55:59) [GCC 12.3.0] on linux
    Type 'help', 'copyright', 'credits' or 'license' for more information.

    import ifcopenshell
    ifcopenshell.version

    'v0.7.0-476ab506d'

    ifcopenshell.path

    ['/home/paullee/.local/lib/python3.10/site-packages/ifcopenshell']

    import ifcopenshell.util.pset
    ifcopenshell.util.pset.PsetQto("IFC4X3")

    Traceback (most recent call last):
    File "", line 1, in
    File "/home/paullee/.local/lib/python3.10/site-packages/ifcopenshell/util/pset.py", line 47, in init
    path = str(folder_path.joinpath("schema", self.templates_path[schema]))
    KeyError: 'IFC4X3'

    (sorry, off-topic too long)

  • @paullee ifcopenshell-python-310-v0.7.0-476ab50-linux64.zip is still outdated
    https://github.com/IfcOpenShell/IfcOpenShell/commit/476ab506d is Feb 15
    pset library for ifc4x3 was added at Feb 23 - https://github.com/IfcOpenShell/IfcOpenShell/commit/708dc6a

    paullee
  • I apologise, the docs haven't been regenerated in a while, my bad. The good news is that there is a new build out literally yesterday:

    https://github.com/IfcOpenBot/IfcOpenShell/commit/fc50bdd3a0354cf332ad846f0a336a9bbfd4a769

    Note that we won't update the docs just yet, since there is a release today and the build contains some potentially dangerous changes related to drawing generation, so it might only be updated in another few weeks after testing.

    paullee
  • Thanks Moult, the pre-built zip is updated today right?
    I'll try again.

    (Compiling is too demanding to me :) )

  • OK @Moult, the link you point to has the latest build.
    (The blenderbim link https://blenderbim.org/docs-python/ifcopenshell-python/installation.html still point to outdated build)

    Some message return on importing -

    import ifcopenshell

    No stream support: No module named 'lark'

    But it seems "IFC4X3" working, thanks !

    ifcopenshell.version

    'v0.7.0-fc50bdd3a'

    import ifcopenshell.util.pset
    ifcopenshell.util.pset.PsetQto("IFC4X3")

    <ifcopenshell.util.pset.PsetQto object at 0x7f3955436d70>

  • Indeed, stream support was just added (we might delay the import to prevent that annoying message). We'll delay regenerating the docs for a few weeks.

    paullee
Sign In or Register to comment.