Imports an Industry Foundation Classes (IFC) file into a database and creates three structured tables for IFC objects, geometry, and materials.
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 of the IFC tables created by this function. |
url | The path to the IFC file in an object storage service, such as an Object Storage Service (OSS) bucket. For the supported path formats, see Object storage paths. |
content | The binary content of the IFC file. Use this parameter to import IFC data directly from memory instead of reading from object storage. |
options | The import options in JSON format. Default value: {}. |
`options` fields
| Field | Type | Default | Description |
|---|---|---|---|
schema | String | public | The schema name of the destination tables. |
project | String | — | The project name. The value is written to the project_name field of every imported record. |
Description
ST_ImportIFC parses an IFC file and loads its contents into three database tables prefixed with the value of prefix. The function supports two input modes:
Object storage: Pass a URL pointing to an IFC file in an OSS bucket or another supported object storage service.
Binary data: Pass the raw binary content of an IFC file loaded into memory.
Limitations
The following IFC data types are not imported:
IfcOpeningElement— data of this type is ignored.Orphan nodes that cannot be attached to the
IfcProjectnode are ignored.IfcElementType— data of this type is temporarily ignored.
Output tables
After a successful import, the function creates three tables in the database.
IFC object table
Table name: [prefix]_ifc_elem
Stores all IFC objects and their attributes.
| Field | Type | Description |
|---|---|---|
id | serial | The row ID. |
family | text | The IFC family of the component. In most cases, the value is IfcBuildingElement or IfcSpatialStructureElement. |
project_uuid | text | The UUID of the root node (IfcProject) in the IFC file. |
project_name | text | The project name set via the project option. Empty if not specified. |
parent_uuid | text | The UUID of the parent component. For components of the IfcProject type, the value is root. |
uuid | text | The UUID of the component, matching its UUID in the source IFC file. |
name | text | The name of the component, inherited from the Name attribute of IfcRoot. |
attrs | jsonb | The fixed attributes of the component. |
props_set | jsonb | The non-fixed property set of the component. For details, see IfcRelDefinesByProperties. |
element | sfmesh | The mesh geometry of the component. |
Geometry component table
Table name: [prefix]_ifc_geom_elem
Stores all geometric objects in the IFC file.
| Field | Type | Description |
|---|---|---|
id | serial | The row ID. |
project_uuid | text | The UUID of the project, matching project_uuid in the IFC object table. |
project_name | text | The project name. Empty if not specified. |
geometry_id | text | The geometry ID of the component, derived from its geometric and material characteristics. |
geom_element | sfmesh | The geometry data of the component. |
IFC material table
Table name: [prefix]_ifc_material_elem
Stores all material objects referenced in the IFC file.
| Field | Type | Description |
|---|---|---|
id | serial | The row ID. |
project_uuid | text | The UUID of the project, matching project_uuid in the IFC object table. |
project_name | text | The project name. Empty if not specified. |
material_name | text | The name of the material. |
material_element | material | The material data of the component. |
Examples
Example 1: Import from OSS without specifying a project name
SELECT ST_ImportIFC('Building', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_ifc');Output:
---------
tExample 2: Import from OSS 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"}');Output:
---------
tBoth examples use the OSS internal endpoint for the China (Beijing) region. Replace <ak> and <ak_secret> with your AccessKey ID and AccessKey Secret, and replace mybucket/path_to_ifc with the actual bucket name and file path.