How to extrude a square, rectangular,... section along a polyline passing through many points?

Here is the code for swept_curve
builder = ifcopenshell.util.shape_builder.ShapeBuilder(model)

Sweep a 10mm radius disk along a polyline with a couple of straight segments and an arc.

curve = builder.polyline(
[(10., 20., 30.), (100., 0., 50.), (171., 29., 51.), (200., 100., 52.), (200., 200., 53.)],
arc_points=[2])
swept_curve = builder.create_swept_disk_solid(curve, 10)

Create a body representation

body = ifcopenshell.util.representation.get_context(model, “Model”, “Body”, “MODEL_VIEW”)
representation = builder.get_representation(body, swept_curve)

The difference between a disk and a square is that the disk is invariant to rotation around the local axis of the directrix. So in that case you not only need a polyline that gives you the location, but you also need to have an orientation when move along the directrix. This is what IfcSurfaceCurveSweptAreaSolid does. The curve must lie on the surface and the local surface normal defines the orientation of the swept profile. Alternatively you can look at the new infrastructure additions such as IfcSectionedSolidHorizontal.

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}")

i don’t know why, but this is error information.

Exception has occurred: IndexError
list index out of range
File “C:\Users\ズオン\Desktop\ifcopenshell\IfcSectionedSolidHorizontal.py”, line 51, in
sectioned_solid_horizontal = model.create_entity(“IfcSectionedSolidHorizontal”,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range

@NTD This is a general forum for IFC, not for specific implementations. See Issues · IfcOpenShell/IfcOpenShell · GitHub