Appearance
Export
Serialize the model to a downloadable 3D file. core.io.export.model returns the file's bytes as base64 — no download dialog opens; the plugin decides what to do with the result (save it, POST it, diff it). Accessed via snaptrude.core.io.export.
Four formats:
"glb"/"obj"— serialized entirely in the browser (nothing is uploaded). Only real model geometry is exported — walls, slabs, roofs, floors, doors, windows, furniture, staircases, masses, ceilings, mullions, beams, columns, terrain. UI helpers, user-hidden objects, and hidden-bucket objects are excluded, matching the app's GLB export."fbx"/"3ds"— the scene is uploaded to the same/exportmodel/conversion service the app's Export dialog uses, and the call resolves once the converted artifact is fetched back: a zip (application/zip) containing the.fbx/.3dsfile. Whole-scene only (scope: "selection"is rejected); the serialized scene excludes hidden-bucket objects, exactly like the dialog. Conversion runs on the server and is bounded by the per-call plugin timeout (60 s) — very large models may exceed it and reject withTIMEOUT.
This is a read: it never mutates the model.
Server-backed BIM exports (RVT / IFC / DWG) are not exposed here — those run as fire-and-forget Forge jobs that stream a browser download and return no retrievable bytes. Use the app's Export menu for those.
Functions
model(format, scope?)
Export the model to a 3D file and return its bytes as base64.
- Parameters:
format:"glb" | "obj" | "fbx" | "3ds"—"glb"= binary glTF (geometry + materials,model/gltf-binary);"obj"= Wavefront OBJ text (geometry only,text/plain);"fbx"/"3ds"= server-converted, returned as a zip (application/zip)scope:"scene" | "selection"(optional, default"scene") — the whole model, or only the currently selected objects. Browser formats only:"fbx"/"3ds"reject"selection". An empty selection yields an empty file.
- Returns:
{ fileName: string; mimeType: string; dataBase64: string }— e.g."model.glb","model.fbx.zip" - Throws: if the format is unsupported,
"selection"is combined with a server format (VALIDATION), or the serialization/conversion fails (OPERATION_FAILED)
ts
// Export the whole model as GLB, then save/download it in the plugin UI:
const file = await snaptrude.core.io.export.model("glb");
const bytes = Uint8Array.from(atob(file.dataBase64), (c) => c.charCodeAt(0));
const blob = new Blob([bytes], { type: file.mimeType });
// ...offer `blob` for download as `file.fileName` ("model.glb")
// Only the current selection, as OBJ text:
const obj = await snaptrude.core.io.export.model("obj", "selection");
const text = atob(obj.dataBase64);
console.log(text.slice(0, 80)); // "# ..." OBJ header
// FBX via the export service — resolves with a zip containing model.fbx:
const fbx = await snaptrude.core.io.export.model("fbx");
console.log(fbx.fileName, fbx.mimeType); // "model.fbx.zip" "application/zip"Errors
Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:
| Code | When |
|---|---|
VALIDATION | Unrecognized format, or scope: "selection" combined with "fbx"/"3ds" (server formats are whole-scene) |
OPERATION_FAILED | The /exportmodel/ conversion request failed, returned no artifact URL, or the artifact fetch failed |
TIMEOUT | The conversion exceeded the 60 s per-call plugin timeout (large models) |