Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'IfcAPI') #156

Open
ctrlmaniac opened this issue May 6, 2024 · 0 comments
Open

Cannot read properties of undefined (reading 'IfcAPI') #156

ctrlmaniac opened this issue May 6, 2024 · 0 comments

Comments

@ctrlmaniac
Copy link

ctrlmaniac commented May 6, 2024

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);
      },
    );
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant