xeokit-convert
xeokit-convert copied to clipboard
Cannot read properties of undefined (reading 'IfcAPI')
As mentioned in #154, I'm getting an error of type: Cannot read properties of undefined (reading 'IfcAPI')
this is my configuration:
import { paths } from "./server-helpers";
import { existsSync, mkdirSync, writeFileSync } from "fs";
import { join } from "path";
import { convert2xkt } from "@xeokit/xeokit-convert/dist/convert2xkt.cjs.js";
import { sourceConfigs } from "./xktconverterconfigs";
import WebIFC from "web-ifc";
export async function createXkt(ifcFileName: string) {
const media = paths.media;
const source = join(media, "buildings", "ifc", ifcFileName);
const dest = join(media, "/buildings", "xkt", ifcFileName + ".xkt");
// crea la cartella "buildings/xkt" se questa non esiste
if (!existsSync(join(media, "buildings", "xkt"))) {
mkdirSync(join(media, "buildings", "xkt"));
}
if (!existsSync(source)) {
console.error("File IFC non esistente");
} else {
// Converte il file ifx in xkt
convert2xkt({
WebIFC,
source: source,
configs: {
sourceConfigs: sourceConfigs
},
output: (buffer) => {
writeFileSync(dest, buffer);
},
log: (msg) => {
console.log(msg);
},
}).then(
() => {
console.log("Converted.");
},
(errMsg) => {
console.error("Conversion failed: " + errMsg);
},
);
}
}