简体   繁体   中英

ifcManager.getAllItemsOfType() ran into error

I am using the ifcLoader.ifcManager.getAllItemsOfType() function from ifc.js I put the function inside the load method, so that after loading a ifc file, it should be print all the slab properties.

const modelID = 0;

  async function logAllSlabs(){
    const slabsID = await ifcLoader.ifcManager.getAllItemsOfType(modelID, IFCSLAB);

    for(let i = 0; i <= slabsID.length; i++) {
        const slabID = slabsID[i];
        const slabProperties = await ifcLoader.ifcManager.getItemProperties(0, slabID);
        console.log(slabProperties);
    }
  }
// IFC loading
  const ifcLoader = new IFCLoader();
  
  const input = document.getElementById('file-input')
  input.addEventListener('change', async () => {
    console.log('file selected')
    const file = input.files[0];
    const url = URL.createObjectURL(file);
    const model = await ifcLoader.loadAsync(url);
    scene.add(model);
    ifcModels.push(model);
    logAllSlabs()
  });

It seems work fine at the beginning, then there's this error. Cannot convert "undefined" to unsigned int

picture


Here is the code. https://github.com/ChenChihYuan/ifcjs_notes/blob/main/02_properties_WIT/app.js

Any suggestions will be thankful.

At a very quick glance, it looks like you're processing one too many items in your for statement:

You have:
for(let i = 0; i <= slabsID.length; i++) {

Since you're starting at zero, you should stop at length:
for(let i = 0; i < slabsID.length; i++) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM