在查看器中检索所选项的属性类别

时间:2017-10-25 10:20:40

标签: autodesk-forge autodesk-viewer

使用getProperties()函数,我得到一个带有properties数组的项目。

在每个属性中,我有一个名为displayCategory的变量。

是否有办法列出商品的不同displayCategory

感谢。

1 个答案:

答案 0 :(得分:0)

正如Philippe Leefsma在this评论中所述,可能的解决方案是:

  • 遍历属性数组并按类别对它们进行分组。
  • 调用this模型衍生产品API端点

我最终使用lodash迭代aray。这是代码:

this.viewer.getProperties(object,
        function(item) {
          item.properties = _.chain(item.properties)
            .groupBy('displayCategory')
            .toPairs()
            .map(function(property) {
              return _.zipObject(['displayCategory', 'properties'], property);
            })
            .value();

        that.selectedItems.push(item);
    },
    function(error) {
      console.log(error);
    });
相关问题