Skip to main content

Posts

IfcOpenShell: Minimal Console Application in Python

This is a first, very basic example of a minimal console IFC application, written in Python and using the ifcopenshell library. First steps - preparation Create a file called  minimal.py . Let's start with importing the necessary Python libraries and provide a main function, so we can run a program from a terminal. The only thing this does right now is reading a file from the arguments and open it using ifcopenshell. There is no error catching, so you best provide it with a valid file and format. python minimal.py IfcOpenHouse.ifc This is the starting point of the source code in the Python file. import sys import ifcopenshell # Our Main function def main (): ifc_file = ifcopenshell . open ( sys . argv [ 1 ]) if __name__ == "__main__" : main () Print the Spatial Hierarchy We will ask for the one and only  IfcProject , which returns a list of items, but it should actually only contain a single item. Nonetheless, we prefer to write this as such so wh...

Getting BIM data into Unity (Part 9 - using IfcConvert)

This is part 9 of a series of posts about getting BIM data into Unity. In this post, we’ll discuss the IfcConvert utility from the IfcOpenShell Open Source IFC Library to preprocess an IFC model for integration with Unity. This is (finally?) again a coding post, with some scripts which are shared to build upon. Conversion of IFC into Unity-friendly formats The strategy with this approach is that you preprocess the IFC-file into more manageable formats for Unity integration. Most Web-platforms do some sort of pre-processing anyway, so what you see in your browsers is almost never an IFC-file, but an optimised Mesh-based geometric representation. However, it wouldn’t be BIM-related if we’d limit ourselves to the geometry, so we will parse the model information as well, albeit using another, pre-processed file. IFC to Wavefront OBJ I used a test IFC-model and used the IfcConvert-utility converted it into OBJ en XML formats. The default way to use it is very simple: ...