ifcpatch.recipes.Migrate¶
Module Contents¶
- class ifcpatch.recipes.Migrate.Patcher(file: ifcopenshell.file, logger: logging.Logger | None = None, schema: ifcopenshell.util.schema.IFC_SCHEMA = 'IFC4')¶
Bases:
ifcpatch.BasePatcherMigrate from one IFC version to another.
The recipe iterates every entity in the source file and rewrites it into a new file with the target schema, delegating per-entity class / attribute translation to
ifcopenshell.util.schema.Migrator. Upgrades (IFC2X3 → IFC4, IFC4 → IFC4X3) are best supported because the target schema is a superset; downgrades are lossy by definition (see below). Entities that fail to migrate are collected; on completion a summaryRuntimeErroris raised listing up to 20 failures.IFC4 → IFC2X3 downgrade additionally runs a preprocessing pipeline so IFC4-only geometry and element classes survive the schema gap:
IfcIndexedPolyCurve(including arc segments, approximated by a chord polyline) is flattened toIfcPolyline.IfcPolygonalFaceSetandIfcTriangulatedFaceSetare converted directly toIfcFacetedBrepat the entity level, preserving the original mesh topology.Orphan IFC4-only geometry instances left over after the rewires are purged so the migration loop does not trip on them.
IFC4-only
IfcElementsubclasses (IfcLamp,IfcPipeSegment,IfcGeographicElement, …) fall back toIfcBuildingElementProxyvia the Migrator’sfallback_element_to_proxyopt-in. The original class andPredefinedTypeare encoded intoObjectType(e.g."IfcLamp/COMPACTFLUORESCENT") whenObjectTypeis empty, so the type information survives the downgrade.
Non-element IFC4-only entities (relationships, geometry items outside any product, …) that have no direct equivalent still raise
NotImplementedErrorfrom the Migrator with the failing class and inverse references named, instead of the crypticEntity with name '' not found in schema 'IFC2X3'.- Parameters:
schema – The schema identifier of the IFC version to migrate to.
Example:
# Upgrade an IFC2X3 model to IFC4 ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "Migrate", "arguments": ["IFC4"]})
- patch()¶
- schema = 'IFC4'¶