MCPcopy Create free account
hub / github.com/ThatOpen/engine_web-ifc / WithIFCFileLoaded

Function WithIFCFileLoaded

examples/usage/src/utils.ts:9–35  ·  view source on GitHub ↗
(name: string, usageExample: (ifcapi: WebIFC.IfcAPI, modelID: number) => void, settings?: WebIFC.LoaderSettings)

Source from the content-addressed store, hash-verified

7let clog = console.log.bind(console);
8
9export async function WithIFCFileLoaded(name: string, usageExample: (ifcapi: WebIFC.IfcAPI, modelID: number) => void, settings?: WebIFC.LoaderSettings) {
10 console.log("Start " + chalk.green(`${name}`));
11
12 console.log = function () {
13 clog.apply(this, [chalk.gray(`[${name}]:`), ...arguments]);
14 }
15 const ifcData = fs.readFileSync(FILE_NAME);
16
17 const ifcapi = new WebIFC.IfcAPI();
18 // ifcapi.SetWasmPath("node_modules/web-ifc/");
19 ifcapi.SetWasmPath("./");
20 await ifcapi.Init();
21
22 let rawFileData = new Uint8Array(ifcData)
23
24 let modelID = ifcapi.OpenModel(rawFileData, settings);
25
26 let startTime = WebIFC.ms();
27 usageExample(ifcapi, modelID);
28 let endTime = WebIFC.ms();
29
30 console.log = clog;
31
32 console.log("End " + chalk.green(`${name}`) + chalk.yellow(` (${endTime - startTime} ms elapsed)`));
33
34 ifcapi.CloseModel(modelID);
35}
36
37export function Equals(name: string, value: any, expectedValue: any) {
38 if (value !== expectedValue) {

Callers 5

coordination.tsFile · 0.90
exporting.tsFile · 0.90
geometrystream.tsFile · 0.90
properties.tsFile · 0.90
modification.tsFile · 0.90

Calls 4

SetWasmPathMethod · 0.95
InitMethod · 0.95
OpenModelMethod · 0.95
CloseModelMethod · 0.95

Tested by

no test coverage detected