0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IfcOpenShell python でIFCファイルに壁を追加してみる

Last updated at Posted at 2020-11-09

はじめに

IFCファイルとは

Industry Foundation Classesの仕様に基づき作成されたファイルのことです。
建設業界にて、建設に使用される要素(壁・窓・ドア・建物設備など)が含まれます。そのためIFCファイルがあれば、ビジュアライズアプリなどを用い3Dでビルを再現することも可能です。

スコープ

・環境構築
・既存のIFCファイルを読み込む
・サンプルの壁を追加する
・新しいIFCファイルとして出力する

環境構築

IfcOpenShellのダウンロード

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

pythonocc-coreのインストール

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

IFCファイルに壁を追加する

import ifcopenshell
from ifcopenshell import geom

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

# 既存のIFCファイルを読み込む
ifc_file = ifcopenshell.open("sample.ifc")

# 新規作成する壁のテンプレートを読み込む
sample_wall = ifc_file.createIfcWall()

# 座標を設定する
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)

# 形状を設定する
axis_representation = ifc_file.createIfcShapeRepresentation(context, "Axis", "Curve2D", [polyline])
product_shape = ifc_file.createIfcProductDefinitionShape(None, None, [axis_representation])

# 新規壁を追加する
sample_wall.Representation = product_shape
ifc_file.add(sample_wall.Representation)

# 別ファイルとして書き出す
ifc_file.write("sample_new.ifc")

参考

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

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?