Autodesk Forge:查看器扩展名不能使用.getExternalIdmap()

class IBSProgressExtension extends Autodesk.Viewing.Extension{
    constructor(viewer, options) {
        super(viewer, options);
    }
    load() {
        //For proof of concept project, I will simply store the externalIds here in a variable.
        const allExternalIds = [
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-0006879a',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-000688ee',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068961',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068963',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a78',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0d',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a0f',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a11',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068a13',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c2f',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c31',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068c33',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b2e',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b30',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b32',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b34',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3e',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b36',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b38',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3a',
            '8a00f4c7-0709-4749-88b6-abb0ddccf965-00068b3c'
        ];

        this.viewer.model.getExternalIdMapping(data => onSuccessMapping(data));

        function onSuccessMapping(data) {
            const resArray = [];
            allExternalIds.forEach(externalId => {
                if (data[externalId]) resArray.push(data[externalId], externalId);
            });
            console.log(resArray);
        };

        console.log('IBSProgressExtension is loaded.');
        return true;
    }
};


Autodesk.Viewing.theExtensionManager.registerExtension("IBSProgressExtension", IBSProgressExtension);

请查看我的分机,并帮助我找出为什么会发生这种情况。 每次我运行它时,DevTools都会记录:ViewerExtension.js:31未捕获的类型错误:无法读取未定义的属性(读取‘getExternalIdmap’)。


解决方案

关于这一点,我在这个阶段尝试实现三件事。

  1. Mongodb获取externalIds
  2. 将外部ID与从getExternalIdMapping()获取的ID进行比较。
  3. 获取DbIds个匹配项。

通过认识到2和3可以放在.loadDocumentNode()之后的a.then()中来解决这些问题。 我已完成mongoose.find()

相关文章