[英]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.我正在使用 ifc.js 中的ifcLoader.ifcManager.getAllItemsOfType()
ifc.js
我将 function 放在 load 方法中,以便在加载 ifc 文件后,它应该打印所有平板属性。
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无法将“未定义”转换为无符号整数
Here is the code.这是代码。 https://github.com/ChenChihYuan/ifcjs_notes/blob/main/02_properties_WIT/app.js 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:乍一看,您似乎在 for 语句中处理了太多项目:
You have:你有:
for(let i = 0; i <= slabsID.length; i++) { for(让 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++) { for(让 i = 0; i <slabsID.length; i++) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.