ThatOpen / engine_web-ifc

Reading and writing IFC files with Javascript, at native speeds.
https://thatopen.github.io/engine_web-ifc/demo
Mozilla Public License 2.0
617 stars 190 forks source link

[Bug]: Error while loading properites in newer versions #402

Closed LukasKStavario closed 1 year ago

LukasKStavario commented 1 year ago

What happened?

Hi, I have simple IFC model (I cannot Add it here directly - link https://uloz.to/tamhle/eZET4Bit1HFS#!ZGSxZwR2ATSwLwR3AmNlMzDlLmL0ASATFQSdoSczpGO3nGR1BD==) And if I am openning it on version 0.0.36 everything works fine (geometry and data) if I open it in my viewer on 0.0.39 and above (or yours - https://ifcjs.github.io/web-ifc-viewer/example/index) and try to get props it causes an error, can you look at it? I need to update web-ifc at least to 0.0.39 because of another models in 4x3 specification that 0.0.36 cannot load succesfully, but my case is focused on data usage and without props I cannot use it.

Log is from your demo.

Version

0.0.40

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge

Relevant log output

in.js:108675 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '1095909175')
    at IfcAPI2.GetLine (main.js:108675:70)
    at WebIfcPropertyManager.getItemProperties (main.js:115905:31)
    at PropertyManager.getItemProperties (main.js:116247:34)
    at IFCManager.getItemProperties (main.js:117619:32)
    at IfcManager.getProperties (main.js:118629:56)
    at window.ondblclick (main.js:138444:40)
G

Anything else?

No response

beachtom commented 1 year ago

I'm really not sure how this came about - but I think it is actually a bug in web-ifc-viewer

LukasKStavario commented 1 year ago

Just load the model in your demo ( https://ifcjs.github.io/web-ifc-viewer/example/index) and double click element. In my case getting spatial structure, but the bug is the same by your side (0.0.36) works fine with this model.

LukasKStavario commented 1 year ago

in this code I cannot read the props - async serializeAllProperties( model: IFCModel, maxSize?: number, event?: (progress: number, total: number) => void, format = false ) {

this.webIfc = this.loader.ifcManager.ifcAPI;
if (!model) throw new Error('The requested model was not found.');
const blobs: Blob[] = [];
console.log('tady0');
let geometriesIDs = await this.getAllGeometriesIDs(model.modelID);
console.log(geometriesIDs);
let properties: any = {
  coordinationMatrix: await this.webIfc!.GetCoordinationMatrix(model.modelID),
  globalHeight: 0
};
try {
  properties.globalHeight = await this.getBuildingHeight(model.modelID);
}
catch (e) {
  console.log(e);
}
console.log('parsing there');
// let properties = await this.initializePropertiesObject(model.modelID);
const allLinesIDs = await this.webIfc!.GetAllLines(model.modelID);
// console.log(allLinesIDs);
const linesCount = allLinesIDs.size();
let lastEvent = 0.1;

let counter = 0;
for (let i = 0; i < linesCount; i++) {
  const id = allLinesIDs.get(i);
  console.log(id);
  if (!geometriesIDs.has(id)) {
    try {
      const props = await this.webIfc!.GetLine(model.modelID, id);
      if (format) {
        if (props.type) {
          // @ts-ignore
          props.type = this.loader.ifcManager.typesMap[props.type];
        }
        this.formatItemProperties(props);
      }
      properties[id] = props;
    } catch (e) {
      // console.log(e);
      // console.log(`There was a problem getting the properties of the item with ID ${id}`);
    }
    // eslint-disable-next-line no-await-in-loop
    // await this.getItemProperty(model.modelID, id, properties, format);
    // console.log(properties);
    counter++;
  }
  if (maxSize && counter > maxSize) {
    blobs.push(new Blob([JSON.stringify(properties)], { type: 'application/json' }));
    properties = {};
    counter = 0;
  }
  if (event && i / linesCount > lastEvent) {
    event(i, linesCount);
    lastEvent += 0.1;
  }
}

blobs.push(new Blob([JSON.stringify(properties)], { type: 'application/json' }));
// await this.getPropertiesAsBlobs2(model.modelID, blobs, maxSize, event, format);
return blobs;

}

beachtom commented 1 year ago

OK so it looks like that model is IFC4x1 which we don't actually support. If you rename the IFC type in the file to IFC4 it does parse correctly at least in web-ifc. I think this is the cause of the issues.

What we do need to do is make web-ifc support these odd versions names and translate them to the closest actual IFC release

LukasKStavario commented 1 year ago

Ok, in this model it works replace 4x1 with 4. I have several questions:

1) Why it works fine on 0.0.36? 2) Do you plan to implement this for IFC4x1 and if so when? 3) My main problem is in model 4x3 that cannot been rendered in 0.0.36 (do not know why - error in WASM) if I put it in demo with 0.0.40 geometry loads fine, but data throws this exception image

If I change the schema to IFC4 (on 4x3) model it throws another exception image

Is it the same problem? I need to have this model loaded with data please 😄 I can send model by link in email (66 megabytes) Thanks for your answers

LukasKStavario commented 1 year ago

I think it is caused by the IFC contains this type of geometry, that your parser does not know. https://search.bsdd.buildingsmart.org/Classification/Index/71073

Where can I fix it?

beachtom commented 1 year ago

OK so you are right we need to solve for these schema versions between releases but if you change the schema type to IFC4X3 it should work

LukasKStavario commented 1 year ago

No, I think we don't understand each other. The main problem I have is with the file that is in the 4x3 scheme because it (my file) contains "IfcBuiltElement" if I manually override the "IfcBuiltElement" class to "IfcBuildingElementProxy" everything works as it should. But I'd like IFC.js to be able to read "IfcBuiltElement" straight away, and I don't expect it to take much effort. Do you want this model?

beachtom commented 1 year ago

So from what I can see the issue is that the schema identifier in the file (on the top of the thread) if IFC4X1. We don't actually support this (I will add a way to parse this soon though) - but it can be parsed with the IFC4X3 parser. So if you change the schema heading the file it will work (or at least it does for me in https://ifcjs.github.io/web-ifc/demo/).

I think the second issue is web-ifc-viewer is still using an older version of the parser - so that does need to be updated to use the latest version

LukasKStavario commented 1 year ago

Sorry I mentioned, that main problem is with different file (large and private) and I can send it to you by the email. Model in the issue is bad example (i thought that problem is the same but not). How can I send it to you?

beachtom commented 1 year ago

Right sorry! So you could email to the IFC JS email address - or if you are on discord I am beachtom you can send me a link - that is probably the quickest way

LukasKStavario commented 1 year ago

I have sent it to your(github logged) email. If you need some more info or something else contact me, thank you.

LukasKStavario commented 1 year ago

Mismatch between version web-ifc in app and viewer.