Try adding a wall to your IFC file with IfcOpenShell python

Introduction

What is an IFC file?

A file created based on the Industry Foundation Classes specifications. Includes elements used in construction (walls, windows, doors, building equipment, etc.) in the construction industry. Therefore, if you have an IFC file, you can reproduce the building in 3D using a visualization application.

scope

·Environment -Read an existing IFC file ・ Add a sample wall -Output as a new IFC file

Environment

Download IfcOpenShell

conda install -c conda-forge -c oce -c dlr-sc -c ifcopenshell ifcopenshell

Install pythonocc-core

conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core

Add a wall to your IFC file

import ifcopenshell
from ifcopenshell import geom

settings = ifcopenshell.geom.settings()
settings.set(settings.USE_PYTHON_OPENCASCADE, True)

#Read an existing IFC file
ifc_file = ifcopenshell.open("sample.ifc")

#Load the newly created wall template
sample_wall = ifc_file.createIfcWall()

#Set the coordinates
context = ifc_file.by_type("IfcGeometricRepresentationContext")[0]
point1 = ifc_file.createIfcCartesianPoint((0.0, 0.0, 0.0))
point2 = ifc_file.createIfcCartesianPoint((5.0, 0.0, 0.0))
ifcpts = []
ifcpts.append(point1)
ifcpts.append(point2)
polyline = ifc_file.createIfcPolyLine(ifcpts)

#Set the shape
axis_representation = ifc_file.createIfcShapeRepresentation(context, "Axis", "Curve2D", [polyline])
product_shape = ifc_file.createIfcProductDefinitionShape(None, None, [axis_representation])

#Add a new wall
sample_wall.Representation = product_shape
ifc_file.add(sample_wall.Representation)

#Export as a separate file
ifc_file.write("sample_new.ifc")

reference

Creating a simple wall with property set and quantity informationTry to create the Wall by myself

Recommended Posts

Try adding a wall to your IFC file with IfcOpenShell python
Try to draw a life curve with python
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
I want to write to a file with Python
Try to make a command standby tool with python
Try to bring up a subwindow with PyQt5 and Python
Try to decipher the garbled attachment file name with Python
Try to operate Facebook with Python
Output to csv file with Python
A story about adding a REST API to a daemon made with Python
Try to create a python environment with Visual Studio Code & WSL
Try to extract a character string from an image with Python3
[ROS2] How to play a bag file with python format launch
Try to reproduce color film with Python
Creating a simple PowerPoint file with Python
Try HTML scraping with a Python library
Try drawing a map with python + cartopy 0.18.0
I made a configuration file with Python
[Cloudian # 3] Try to create a new object storage bucket with Python (boto3)
Create a shortcut to run a Python file in VScode on your terminal
Try to solve a set problem of high school math with Python
Try to make your own AWS-SDK with bash
nginxparser: Try parsing nginx config file with Python
Try to calculate a statistical problem in Python
Try to solve the man-machine chart with Python
How to create a JSON file in Python
I want to make a game with Python
Try to automatically generate Python documents with Sphinx
Decide to assign a laboratory with Python (fiction)
Save the object to a file with pickle
Create a Photoshop format file (.psd) with python
Read line by line from a file with Python
Open a file dialog with a python GUI (tkinter.filedialog)
A layman wants to get started with Python
Try to detect fish with python + OpenCV2.4 (unfinished)
Try to solve the traveling salesman problem with a genetic algorithm (Python code)
How to drop Google Docs in one folder in a .txt file with python
WEB scraping with python and try to make a word cloud from reviews
Try scraping with Python.
Parse a JSON string written to a file in Python
How to convert / restore a string with [] in python
Memo to create your own Box with Pepper's Python
Try to solve the programming challenge book with python3
[First API] Try to get Qiita articles with Python
A memo connected to HiveServer2 of EMR with python
Python beginners try adding basic auth to Django admin
Try to make a Python module in C language
Try creating a compressed file using Python and zlib
Python Ver. To introduce WebPay with a little code.
Try to improve your own intro quiz in Python
Perform a Twitter search from Python and try to generate sentences with Markov chains.
Try to dynamically create a Checkbutton with Python's Tkinter
(Python) Try to develop a web application using Django
Convert a text file with hexadecimal values to a binary file
Try to solve the internship assignment problem with Python
I tried to touch the CSV file with Python
I tried to draw a route map with Python
Try embedding Python in a C ++ program with pybind11
A memorandum to run a python script in a bat file
How to measure mp3 file playback time with python