@Coen
No no ? much simpler, I am trying to create an arrow

import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.owner.settings
version = "IFC4"
basename = "My Project"
file = ifcopenshell.api.run("project.create_file", version=version)
person = ifcopenshell.api.run("owner.add_person", file)
person[0] = person.GivenName = None
person.FamilyName = "user"
org = ifcopenshell.api.run("owner.add_organisation", file)
org[0] = None
org.Name = "template"
user = ifcopenshell.api.run("owner.add_person_and_organisation", file, person=person, organisation=org)
application = ifcopenshell.api.run("owner.add_application", file)
ifcopenshell.api.owner.settings.get_user = lambda ifc: user
ifcopenshell.api.owner.settings.get_application = lambda ifc: application
project = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcProject", name=basename)
lengthunit = ifcopenshell.api.run("unit.add_si_unit", file, unit_type="LENGTHUNIT", name="METRE")
ifcopenshell.api.run("unit.assign_unit", file, units=[lengthunit])
model = ifcopenshell.api.run("context.add_context", file, context_type="Model")
context = ifcopenshell.api.run(
"context.add_context",
file,
context_type="Model",
context_identifier="Body",
target_view="MODEL_VIEW",
parent=model,
)
site = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcSite", name="My Site")
building = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcBuilding", name="My Building")
storey = ifcopenshell.api.run(
"root.create_entity", file, ifc_class="IfcBuildingStorey", name="My Storey"
)
ifcopenshell.api.run("aggregate.assign_object", file, product=site, relating_object=project)
ifcopenshell.api.run("aggregate.assign_object", file, product=building, relating_object=site)
ifcopenshell.api.run("aggregate.assign_object", file, product=storey, relating_object=building)
origin = file.createIfcAxis2Placement3D(
file.createIfcCartesianPoint((1.0, 1.0, 0.0)),
file.createIfcDirection((0.0, 0.0, 1.0)),
file.createIfcDirection((1.0, 0.0, 0.0)),
)
placement = file.createIfcLocalPlacement(None, origin)
history = ifcopenshell.api.run("owner.create_owner_history", file)
height = 0.5
origin_cone = file.createIfcAxis2Placement3D(
file.createIfcCartesianPoint((0.0, 0.0, height)),
file.createIfcDirection((0.0, 0.0, -1.0)),
file.createIfcDirection((-1.0, 0.0, 0.0)),
)
cone_rep = file.create_entity("IfcRightCircularCone", Position=origin_cone, Height=height , BottomRadius=0.15)
cone = file.create_entity("IfcCsgSolid", TreeRootExpression=cone_rep )
origin_cylinder = file.createIfcAxis2Placement3D(
file.createIfcCartesianPoint((0.0, 0.0, height)),
file.createIfcDirection((0.0, 0.0, 1.0)),
file.createIfcDirection((1.0, 0.0, 0.0)),
)
cy_rep = file.create_entity("IfcRightCircularCylinder", Position=origin_cylinder, Height=height , Radius=0.05)
cylinder = file.create_entity("IfcCsgSolid", TreeRootExpression=cy_rep )
representation = file.createIfcProductDefinitionShape(
None,
None,
[
file.createIfcShapeRepresentation(
context,
"Body",
"CSG",
[cone, cylinder],
)
],
)
product = file.create_entity(
"IfcBuildingElementProxy",
**{
"GlobalId": ifcopenshell.guid.new(),
"Name": "Arrow",
"ObjectPlacement": placement,
"Representation": representation,
}
)
ifcopenshell.api.run("spatial.assign_container", file, product=product, relating_structure=storey)
file.write("arrow.ifc")