exportGraphicsAsync Method
Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
- This function queues an export task to the thread pool for each provided element ID, and returns a Promise that resolves when all elements have been exported. The onGraphics and onLineGraphics callbacks are invoked in the main thread as each element's export completes. This allows large exports to be performed without blocking the main thread.
- Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
- The results of changing ExportGraphicsOptions during the ExportGraphicsOptions.onGraphics callback are not defined.
Example that prints the mesh for element 1 to stdout in OBJ format
const onGraphics: ExportGraphicsFunction = (info: ExportGraphicsInfo) => {
const mesh: ExportGraphicsMesh = info.mesh;
for (let i = 0; i < mesh.points.length; i += 3) {
process.stdout.write(`v ${mesh.points[i]} ${mesh.points[i + 1]} ${mesh.points[i + 2]}\n`);
process.stdout.write(`vn ${mesh.normals[i]} ${mesh.normals[i + 1]} ${mesh.normals[i + 2]}\n`);
}
for (let i = 0; i < mesh.params.length; i += 2) {
process.stdout.write(`vt ${mesh.params[i]} ${mesh.params[i + 1]}\n`);
}
for (let i = 0; i < mesh.indices.length; i += 3) {
const p1 = mesh.indices[i];
const p2 = mesh.indices[i + 1];
const p3 = mesh.indices[i + 2];
process.stdout.write(`f ${p1}/${p1}/${p1} ${p2}/${p2}/${p2} ${p3}/${p3}/${p3}\n`);
}
};
await iModel.exportGraphicsAsync(({ onGraphics, elementIdArray: ["0x1"] }));
exportGraphicsAsync(exportProps: ExportGraphicsOptions): Promise<void>
@returns A Promise that resolves when the export is complete, or rejects in the case of an error.
| Parameter | Type | Description |
|---|---|---|
| exportProps | ExportGraphicsOptions |
Returns - Promise
A Promise that resolves when the export is complete, or rejects in the case of an error.
Defined in
- core/backend/src/IModelDb.ts Line 1936
Last Updated: 07 February, 2026
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.