B
by bernd on 1 Dec 2020, edited 15 Dec 2023
#
Is it possible to get the Header FILE_DESCRIPTION and FILE_NAME by Python?
HEADER;FILE_DESCRIPTION(('no view'),'2;1');
FILE_NAME('C:\\Users\\BHA\\Desktop\\exporter_new.ifc',
'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','');
FILE_SCHEMA(('IFC2X3'));
ENDSEC;
The schema is possible with ifcos_ifc_class.schema. This is what I know and use.
B
by bernd on 1 Dec 2020
#
BTW: Found this in the regard of the header, but it is quite old ... https://standards.buildingsmart.org/documents/Implementation/ImplementationGuide_IFCHeaderData_Version_1.0.2.pdf
M
by Moult on 1 Dec 2020
#
@bernd yes, using ifc_file.wrapped_data.header
. See:
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/ifcblenderexport/blenderbim/bim/export_ifc.py#L1411
B
by bernd on 1 Dec 2020
#
but this is set_header, for export. I would like to read the data out of a ifc file like get_header ...
M
by Moult on 1 Dec 2020
#
+1 votes
@bernd no, set_header
is simply a function in the BlenderBIM Add-on during the export process. Look at the lines after it.
B
by bernd on 2 Dec 2020, edited 2 Dec 2020
#
got it ... :-)
myifcfile.wrapped_data.header.file_description.description
myifcfile.wrapped_data.header.file_description.implementation_level
myifcfile.wrapped_data.header.file_name.name
...
B
by bernd on 2 Dec 2020
#
How about the comments Revit does write before it even starts the ifc file contents. I assume reading comments is not possible?!
M
by Moult on 2 Dec 2020
#
@bernd good point, I haven't seen a way to access comments. It's a relatively simple string parse, though...
C
by Coen on 28 Jul 2022, edited 28 Jul 2022
#
How would once acces the timestamp in FILE_NAME using IfcOpenShell?
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
FILE_NAME('test_load.ifc','2022-07-28T16:10:23+02:00',(),(),'IfcOpenShell v0.7.0-1b1fd1e6','BlenderBIM 0.0.220516','Nobody');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
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...
G
by Gorgious on 29 Jul 2022
#
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.
A
by Andrej730 on 15 Dec 2023
#
+1 votes
@Coen said:
How would once acces the timestamp in FILE_NAME using IfcOpenShell?
I'm very late to the party, just found this thread looking for similar issues, but it's just ifc_file.wrapped_data.header.file_name.time_stamp
, in similar way as accessing any other header entities.