Skip to content
IFC-RS
Viewer Русский
Project Wiki en

Examples

Rust: Open → Query → Edit → Write

use ifccore::IfcModel;

let source = std::fs::read("model.ifc")?;
let mut model = IfcModel::open(&source);
for wall in model.entities_by_type("IFCWALL") {
    println!("#{} {}", wall.express_id(), wall.type_name());
}
let wall_id = model
    .entities_by_type("IFCWALL")
    .first()
    .map(|wall| wall.express_id());
if let Some(wall_id) = wall_id {
    let mut edit = model.edit();
    // Name is the third explicit IfcRoot attribute, so its position is 2.
    edit.set_attribute(wall_id, 2, "'Updated name'");
    edit.commit()?;
}
let mut output = std::fs::File::create("model-updated.ifc")?;
model.write(&mut output)?;
# Ok::<(), Box<dyn std::error::Error>>(())

Compilable versions live in crates/ifccore/examples/.

Node/WASM

import fs from "node:fs";
import core from "@ifc-core/wasm-node";

const opened = JSON.parse(core.ifc_open(fs.readFileSync("model.ifc")));
try {
  console.log(JSON.parse(core.ifc_query(opened.handle, 1)));
} finally {
  core.ifc_close(opened.handle);
}

Browser clients call the default init() first. Typical flows are:

  • viewer: open → tree/search → properties → geometry → close;
  • edit: preview → confirmed commit → refresh affected entities → export;
  • diagnostics: open → diagnostics/performance report → close;
  • MCP: open_model → find/get/property/relations → close_model.