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.
·Environment -Read an existing IFC file ・ Add a sample wall -Output as a new IFC file
conda install -c conda-forge -c oce -c dlr-sc -c ifcopenshell ifcopenshell
conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core
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")
・ Creating a simple wall with property set and quantity information ・ Try to create the Wall by myself
Recommended Posts