Skip to content

Import an IFC2X3, IFC4 or IFC4X3 and transform it to an ifcJSON

The capability which is demonstrated here is simple: we can import an IFC (Step file) from a remote source and tranform it to an ifcJSON that will be available for the next steps in a straight-through processing manner

Submit the processing request

Import is started by sending a POST with a Json Body as defined in pydantic

class ImportFilter(BaseModel):
    categoryList: list[Literal['construction','furniture','group','material','ownership','project','propertySet','quantity','relationship','representation','space','system']] | None = ['construction','group','material','ownership','project','propertySet','quantity','relationship','representation','space'] 
    excludeTypeList: list[str] | None = ['IfcBuildingElement','IfcBuildingElementPart','IfcBuildingElementProxy','IfcBuildingElementProxyType']

class TesselateElements(BaseModel):
    elementTypes: list[str] | None = ["IfcWall,IfcWallStandardCase,IfcSlab,IfcBeam,IfcColumn,IfcWindow,IfcDoor,IfcSpace"]
    forcedFacetedBREP: bool | None = False

class ImportInstruction(BaseModel):
    sourceFileURL: str | None = "http://localhost:8002/IFC_SOURCE_FILES/AC20-FZK-Haus.ifc"
    modelType: Literal['ifc']
    migrateSchema: bool | None = False
    tessellate: bool | None = True
    spatialUnitId: str | None = "b6fc5402-ca87-47ba-a9f4-e29173d51656"
    parentBundleId : str | None = None  
    bundleId: str | None = None
    withFilter: bool | None = False
    filter: ImportFilter 
    tessellateElements: TesselateElements

FastAPI provides by default at /docs a swagger utility that simplifies the execution of tests.

The request provides:

  • default values that must be adjusted to your specific case
  • the filter (more on that in filter the model)
  • the option to migrate the schema in the IFC file. This applies only to the migration from IFC2X3 to IFC4. There is no migration for IFC schema IFC4 and IFC4X3 and the value of migrateSchema will be ignored
  • the option to tessellate the representation of the products (IfcWall, IfcSlab, ...). To be tessellated, an IFC2X3 must also be migrated to IFC4 (migrateSchema = True). Tessellation is based on IfcPatch with recipe = 'TesselateElements'. The default list of elements is [].

For a new primary import, the parentBundleId and the bundleId must be None, i.e. removed from the request.

Swagger for import on /docs

Service the request

This is done in the Service Layer where a chain of task is composed and sent for execution by a Celery Worker via a message in the Message Broker(Redis)

Get IFC from a remote location

Currently all IFC files are store locally and served with Nodejs http-server.

Migrate the IFC file from IFC2X3 to IFC4 with IfcPatch

This is done with the IfcPatch 'Migrate' recipe before the conversion to ifcJSON provided that migrateSchema is set to True.

Create the ifcJSON with IFC2JSON

Read file and create ifcjson model with NO_INVERSE=True.

Create the Bundle and Update the bundleJournal

flowchart TB
    bundle
    bundleJournal
    spatialUnit
    bundleUnit
    spatialUnitBundleUnit
    spatialUnitBundleUnit --o bundleUnit
    spatialUnitBundleUnit --o spatialUnit
    bundle --o bundleUnit
    bundle --o bundleJournal

The database is updated with:

  • an entry in the bundle table
  • an entry in the bundleJournal table
  • an entry in the bundleUnit as a root entity (the project)
  • an entry in the spatialUnitBundleUnit table

Issues (will need a follow-up)

Note

Tessellate does not maintain the style (this is a known feature / bug). In the present state, tesselation should better not be used on the primary import.

Note

Error with IfcExternalReference not supported. When present, I get the following error: 'AttributeError("entity instance of type 'IFC4.IfcExternalReference' has no attribute 'wrappedValue'")

Note

with NO_INVERSE = False for LARGE_MODEL_20210219Architecture.ifc, the program got stuck somewhere. I stopped after 23m 53.2s