循环遍历所有 ID 时获取 ID 属性的问题 [英] Problems with getting the properties of an ID when looping over all Ids

查看:45
本文介绍了循环遍历所有 ID 时获取 ID 属性的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取所有 dbId 元素的属性.为此,我只是循环遍历我的 dbId 数组并使用 伪造查看器.

I'm interested to get the properties of all dbId elements. For this purpose I'm simply looping over my array of dbIds and use the getProperties function provided by the Forge Viewer.

  someFunction() {

    const instanceTree = this.viewer.model.getData().instanceTree;

    const allDbIds = Object.keys(instanceTree.nodeAccess.dbIdToIndex);

    console.log('all DbIds');
    console.log(allDbIds);

    // This will give the correct Properties
    // this.viewer.getProperties(5, (result) => {
    //   console.log(result)
    // })

    allDbIds.forEach((dbId) => {

      this.viewer.getProperties(dbId, (result) => {
        console.log('result:');
        console.log(result);

      }, (err) => {
        console.log('err');
        console.log(err);
      });
    });
  }

当我直接访问特定的 dbId 时,我会得到正确的属性数组.但是,当循环遍历所有 dbId 并调用 getProperties 函数时,只有前两个 dbId 返回属性,所有其他 dbId 仅返回空数组.此外,前两个数组很大,似乎包含其他属性.--> 控制台输出链接

When I access a specific dbId directly I get the correct property array. However when looping over all dbIds and calling the getProperties function only the first two dbIds are returning properties and all the others are only returning empty arrays. Additionally the first two arrays are way to big and seem to contain the other properties. --> Link to console output

有人知道我在这里做错了什么吗?已经谢谢了!

Does somebody know what I'm doing wrong here? Thanks already!

推荐答案

代替在客户端页面上迭代属性,更好的方法可能是通过 Model Derivative API 一次查询所有属性.请参阅这些参考资料:

Instead of iterating properties on the client page, a better approach might be to query all properties at once via the Model Derivative API. See these references:

https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-metadata-GET/

https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-metadata-guid-properties-GET/

这篇关于循环遍历所有 ID 时获取 ID 属性的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆