Parse Revit file format
pnpm add @phi-ag/rvt
Node.js / Deno / Bun
import { basicFileInfo, thumbnail } from "@phi-ag/rvt";
import { openPath } from "@phi-ag/rvt/node";
const file = await openPath("family.rfa");
const info = await basicFileInfo(file);
const image = await thumbnail(file);
console.log(info);
Browser
import { basicFileInfo, openFile, thumbnail } from "@phi-ag/rvt";
// Get a file handle from <input type="file" accept=".rfa,.rvt" />
// see https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications
const selectedFile = document.getElementById("input").files[0];
const file = await openFile(selectedFile);
const info = await basicFileInfo(file);
const image = await thumbnail(file);
console.log(info);
If you don't want to throw errors, use tryOpenPath
, tryOpenFile
, tryBasicFileInfo
and tryThumbnail
tryOpenPath("valid.rvt");
// => { ok: true; data: ... }
tryOpenPath("invalid.rvt");
// => { ok: false; error: "Error message" }
tryBasicFileInfo("valid.rvt");
// => { ok: true; data: { version, build, ... } }
tryBasicFileInfo("invalid.rvt");
// => { ok: false; error: "Error message" }