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

查看:157
本文介绍了遍历所有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/zh-CN/docs/model-derivative/v2/reference/http/urn-metadata-guid-properties-GET/

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

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