M
by Martin156131 on 3 Aug 2022, edited 10 Aug 2022
#
When opening a ifc file in Python, i didn't find a method to close it.
This is the method to open a ifc file written hear https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples
import ifcopenshell
file = ifcopenshell.open('/path/to/your/file.ifc')
However there is no method to close the file?
And should we generally open files with the "with" statement ?
https://www.geeksforgeeks.org/with-statement-in-python/
V
by vpajic on 4 Aug 2022
#
+3 votes
@Martin156131 I don't think you need to worry about that. When you run ifcopenshell.open(), what you get back is the base class for handling ifc files. There's nothing you need to close, and there's not really a need for 'with' in this case.
G
by Gorgious on 10 Aug 2022
#
AFAIK it's not keeping the file open, it's reading its content, recreating it in memory, and then closing the file, all in ifcopenshell.open
. When you save the blend file down the line the ifc file is overwritten with new information.