Use AI to manipulate your IFC

If you don’t know about ChatGPT, let me tell you about it. It is a useful application that can answer your questions, give you recipes for tasty cakes, and help you write essays. But it can do even more!
ChatGPT is not just for chatting; it is also used to create code that solves programming problems. Because its algorithms keep getting better, it can write code more accurately and efficiently.

In this article, I will show you how to use ChatGPT to help us create code for modifying IFC (Industry Foundation Classes) files. You will see how ChatGPT can streamline working with this format and speed up task execution.

Let’s dive into the article.

If you’re interested in the topic of IFC 4.3, don’t forget to check out other articles dedicated to this subject on our blog.

ChatGPT

In the age of digital transformation, more and more tools are leveraging artificial intelligence (AI) to automate tasks and simplify processes. One such tool is ChatGPT, a language model developed by OpenAI that can assist users in generating code and automating programming tasks.

In this article, I will demonstrate how to use ChatGPT to modify IFC files using Python and the ifcOpenShell library. This library enables the manipulation of IFC files, which are a widely used format in the architectural and engineering industries for storing information about building models.

Workflow

Let’s get into the details. Below, I describe step by step how to use ChatGPT to generate and modify Python code that allows for editing IFC files.

ifcopenshell

Step 1: Creating a Prompt

The first step in using ChatGPT to generate code is preparing a prompt—an instruction that we provide to the language model. The prompt should precisely describe what we want to achieve while remaining concise and clear. It’s advisable not to create overly complex or lengthy prompts. Instead, it’s better to break the task into smaller parts and gradually add more code snippets.

An example prompt for ChatGPT could look like this: “Create Python code that uses the ifcopenshell library to open an IFC file and then modifies the name of a specific building element.”

Step 2: Generating the Code

After creating an appropriate prompt, ChatGPT generates Python code utilizing the ifcOpenShell library. This library is a specialized tool that allows for various manipulations of data within IFC files.

At this stage, the generated code can be relatively simple or more complex, depending on how precisely the requirements were described in the prompts. ChatGPT produces the code according to the given instructions, enabling the user to quickly obtain a functioning script.

Step 3: Using the Code

The generated code should be copied into your programming environment. In this case, I use Google Colab. Before running the code, you need to install the ifcopenshell library using the following command:

				
					pip install ifcopenshell
				
			

Next, you need to upload the IFC file that you want to modify.

Step 4: Iteration

If you encounter errors while running the code, the next step is to copy the error messages and input them into ChatGPT for assistance in fixing the code. This approach makes the debugging process much quicker and more efficient, as ChatGPT can suggest corrections to the code or point out errors that need to be addressed.

Additionally, ChatGPT can help with code refactoring, which involves optimizing the code to make it more efficient or easier to maintain.

Step 5: Modifying and Saving the Changed File

After making the necessary corrections, the code should be ready to implement changes to the IFC file. If all the steps have been executed correctly, the file will be successfully modified according to your requirements. You can then download the modified file and use it in further stages of design or analysis.

Webinar

To further explore the topic, I encourage you to watch the recording of the webinar where I discuss the step-by-step process of creating code for editing IFC files.

Summary

In summary, ChatGPT can be an extremely useful tool for supporting work with IFC files. By generating and modifying Python code using the ifcOpenShell library, you can easily automate complex tasks and accelerate the process of creating and editing BIM models.

I encourage you to try out the methods described and watch the recording of the webinar to gain a better understanding of this process step by step.

Did you like that post ? Share it with others !

We spend a lot of time and effort creating all of our articles and guides. It would be great if you could take a moment to share this post !

Share:

Comments:

Subscribe
Notify of
guest
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments

Author:

Download BIM CASE STUDIES:

After reading this guide you will learn:

  • How BIM is used on the biggest projects in Norway
  • What were the challenges for the design team and how were they solved
  • What were the challenges on the construction site and what was our approach to them

Newest articles: