Imports an Industry Foundation Classes (IFC) file into a database. Returns true on success and creates three tables prefixed with the value you provide.
Syntax
Syntax 1 — import from object storage:
boolean ST_ImportIFC(cstring prefix, cstring url, cstring options default '{}');Syntax 2 — import from binary data:
boolean ST_ImportIFC(cstring prefix, bytea content, cstring options default '{}');Parameters
| Parameter | Description |
|---|---|
prefix | The prefix applied to all three output table names. |
url | The path to the IFC file in object storage. Use this parameter when the file is stored in an Object Storage Service (OSS) bucket. For supported path formats, see Object storage paths. |
content | The binary representation of the IFC file. Use this parameter to import the file by passing its binary data directly, instead of a URL. |
options | A JSON object that controls the import behavior. Defaults to {}. |
Options fields
| Field | Type | Default | Description |
|---|---|---|---|
schema | String | public | The schema of the destination tables. |
project | String | — | A project name written to the project_name column of every imported record. Use this field when one database stores data from multiple sub-projects. |
Output tables
A successful import creates three tables in the database.
[prefix]_ifc_elem — IFC objects
Stores all IFC objects and their attributes. Query this table to retrieve building elements, spatial structure elements, and their properties.
| Field | Type | Description |
|---|---|---|
id | serial | Row ID. |
family | text | The IFC class family of the element, typically IfcBuildingElement or IfcSpatialStructureElement. |
project_uuid | text | UUID of the root IfcProject node in the IFC file. |
project_name | text | The project name set via the project option. Empty if not specified. |
parent_uuid | text | UUID of the parent element. Set to root for elements of type IfcProject. |
uuid | text | UUID of the element, matching the UUID in the source IFC file. |
name | text | Name of the element, inherited from the Name attribute of IfcRoot. |
attrs | jsonb | Fixed attributes of the element. Extend with additional types and attributes as needed. |
props_set | jsonb | Non-fixed property sets of the element. Corresponds to IfcRelDefinesByProperties. |
element | sfmesh | The geometric entity of the element. |
[prefix]_ifc_geom_elem — Geometry components
Stores all geometric objects. Query this table to retrieve and analyze the geometry of building components.
| Field | Type | Description |
|---|---|---|
id | serial | Row ID. |
project_uuid | text | UUID of the project. Matches project_uuid in the IFC object table. |
project_name | text | The project name set via the project option. Empty if not specified. |
geometry_id | text | The geometry ID of the element. The value consists of the geometric and material characteristics of the element. |
geom_element | sfmesh | The geometry data of the element. |
[prefix]_ifc_material_elem — Materials
Stores all material objects. Query this table to look up material definitions associated with building components.
| Field | Type | Description |
|---|---|---|
id | serial | Row ID. |
project_uuid | text | UUID of the project. Matches project_uuid in the IFC object table. |
project_name | text | The project name set via the project option. Empty if not specified. |
material_name | text | The name of the material. |
material_element | material | The material data of the element. |
Limitations
The following data is not imported:
IfcOpeningElement— openings such as door and window cutouts are skipped.Orphan nodes — nodes that cannot be attached to an
IfcProjectnode are skipped.IfcElementType— element type definitions are temporarily skipped.
Examples
Example 1: Import from an OSS bucket without a project name.
SELECT ST_ImportIFC(
'Building',
'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_ifc'
);---------
tExample 2: Import from an OSS bucket with a project name.
SELECT ST_ImportIFC(
'Building',
'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_ifc',
'{"project":"building_1"}'
);---------
tReplace the following placeholders with your actual values:
| Placeholder | Description |
|---|---|
<ak> | Your Alibaba Cloud AccessKey ID. |
<ak_secret> | Your Alibaba Cloud AccessKey secret. |