IfcOpenShell access IFC-SPF header data

edited December 2020 in General

Is it possible to get the Header FILE_DESCRIPTION and FILE_NAME by Python?

HEADER;FILE_DESCRIPTION(('no view'),'2;1');
'2020-10-29T15:57:39',('Bernd Hahnebach'),('My Office AG',
'My Street 32, 9999 My Town'),
'EDMsix Version 2.0100.09 Sep  7 2016',
'Allplan 2020.1 09.09.2020 - 17:35:19','');

The schema is possible with ifcos_ifc_class.schema. This is what I know and use.


  • but this is set_header, for export. I would like to read the data out of a ifc file like get_header ...

  • @bernd no, set_header is simply a function in the BlenderBIM Add-on during the export process. Look at the lines after it.

  • edited December 2020

    got it ... :-)



  • How about the comments Revit does write before it even starts the ifc file contents. I assume reading comments is not possible?!

  • @bernd good point, I haven't seen a way to access comments. It's a relatively simple string parse, though...

  • edited July 28

    How would once acces the timestamp in FILE_NAME using IfcOpenShell?

    FILE_NAME('test_load.ifc','2022-07-28T16:10:23+02:00',(),(),'IfcOpenShell v0.7.0-1b1fd1e6','BlenderBIM 0.0.220516','Nobody');

    It's a relatively simple string parse, though...

    As I understand it is not possible with IfcOpenShell yet... :-)?

    What about something like this?

    import os
    import re
    import bpy
    import ifcopenshell
    from blenderbim.bim.ifc import IfcStore
    ifc_file = ifcopenshell.open(IfcStore.path)
    with open(IfcStore.path) as ifc_text:
        for line_no, line_file in enumerate(ifc_text):
            if line_no  == 3:
                if line_file.startswith("FILE_NAME"):
                    print (line_file.split(',')[1])

    Is the FILE_NAME always on line 4? seems a bit risky method, string parsing...

  • It will work for this specific file but I'm sure it's not that hard to make it fail ^^ What if your file name has a , in it ? I think it would be a bit more robust to check all lines and see if they begin with FILE_NAME and then parse the string with a regular expression to see if something matches a date formating.

Sign In or Register to comment.