sorry sir.
I’m a beginner. Can you show me how to code in python for “IfcSectionedSolidHorizontal”? This is my code. It isn’t work.
import ifcopenshell
import ifcopenshell.api
from ifcopenshell.api import run
import ifcopenshell.util.shape_builder
from ifcopenshell.util.shape_builder import V
model = ifcopenshell.file(schema=‘IFC4X3_ADD2’)
project = run(“root.create_entity”, model, ifc_class=“IfcProject”, name=“My Project”)
run(“unit.assign_unit”, model)
context = run(“context.add_context”, model, context_type=“Model”)
body = run(“context.add_context”, model, context_type=“Model”, context_identifier=“Body”, target_view=“MODEL_VIEW”, parent=context)
site = run(“root.create_entity”, model, ifc_class=“IfcSite”, name=“My Site”)
building = run(“root.create_entity”, model, ifc_class=“IfcBuilding”, name=“Building A”)
storey = run(“root.create_entity”, model, ifc_class=“IfcBuildingStorey”, name=“Ground Floor”)
run(“aggregate.assign_object”, model, relating_object=project, product=site)
run(“aggregate.assign_object”, model, relating_object=site, product=building)
run(“aggregate.assign_object”, model, relating_object=building, product=storey)
wall = run(“root.create_entity”, model, ifc_class=“IfcWall”)
run(“geometry.edit_object_placement”, model, product=wall)
points = [
model.create_entity(“IfcCartesianPoint”, Coordinates=(0.0, 0.0, 0.0)),
model.create_entity(“IfcCartesianPoint”, Coordinates=(0.0, 0.0, 1.0)),
model.create_entity(“IfcCartesianPoint”, Coordinates=(1.0, 0.0, 1.0)),
model.create_entity(“IfcCartesianPoint”, Coordinates=(1.0, 0.0, 0.0)),
]
polyline = model.create_entity(“IfcPolyline”, Points=points)
rectangle_profile = model.create_entity(“IfcRectangleProfileDef”, ProfileType=“AREA”, XDim=0.5, YDim=0.2)
placements = [
model.create_entity(“IfcAxis2Placement3D”, Location=point) for point in points
]
sectioned_solid_horizontal = model.create_entity(“IfcSectionedSolidHorizontal”,
SpineCurve=polyline,
CrossSections=[rectangle_profile] * len(placements),
CrossSectionPositions=placements)
# Assign our new body geometry back to our wall
run(“geometry.assign_representation”, model, product=wall, representation=sectioned_solid_horizontal)
# Place our wall in the ground floor
run(“spatial.assign_container”, model, relating_structure=storey, product=wall)
file_path = “C:/Users/ズオン/Desktop/ifcopenshell/Duong_Thu_cong_SectionedSolidHorizontal.ifc”
model.write(file_path)
print(f"IFC model saved to {file_path}")