我刚刚开始使用 Python 分析 IFC 文件。为此,我将 IfcOpenShell 用于 Python。
我已经设法确定了 x、y、z 的位置、墙的长度和厚度。不幸的是,我失败了,因为我只知道墙的起点。墙去的点我找不到或没有办法计算这个。
有人可以告诉我如何做到这一点的例子吗?
目标是我可以将最后来自 IFC 的数据转换为绘图输出。如果这很简单,也请告诉我。
这是我的代码:
import ifcopenshell
import ifcopenshell.util
import ifcopenshell.util.placement
import ifcopenshell.util.element
import ifcopenshell.geom
import numpy as np
import math as m
with open ("./Desktop/Ausgabe.csv","w",encoding="cp1252") as Datei:
Datei.write("Daten|Wert")
# /home/bot/Testraum.ifc
ifc=ifcopenshell.open("./Desktop/Testraum.ifc")
elements = ifc.by_type('IfcColumn')
print ("Elemente",elements)
settings = ifcopenshell.geom.settings()
unit_scale = 0.001
print ("Schema",ifc.schema)
Datei.write("\r"+"Schema|"+ifc.schema)
walls =ifc.by_type("IfcWall")
print ("Anzahl der Wände",len(walls))
Datei.write("\r"+"Anzahl der Wände|"+str(len(walls)))
for durchlauf in range(len(walls)):
Datei.write("\r"+"--------------------------------------------------------------------------------------------------------------")
Datei.write("\r"+"--------------------------------------------------------------------------------------------------------------")
wall=walls[durchlauf]
daten= (ifcopenshell.util.element.get_psets(wall))
location=ifcopenshell.util.placement.get_local_placement(wall.ObjectPlacement)
Pos=location[0:3,3]
print ("X",Pos[0])
print ("Y",Pos[1])
print ("Z",Pos[2])
print (location[0:3,0])
print (location[0:3,1])
print (location[0:3,2])
print (location[0:3,3])
print ("----")
for Bereich in daten:
daten2=daten[Bereich]
for f in daten2:
Datei.write("\r"+f+"|"+str(daten2[f]))
Datei.write("\r"+"--------------------------------------------------------------------------------------------------------------")
谢谢你的帮助
彼得