更改 Revit 模型视图/几何图形时出现 APS (Forge) Viewer“Autodesk.AEC.LevelsExtension”错误

问题描述 投票:0回答:1

我们在 Revit 模型查看器中使用 Autodesk.AEC.LevelsExtension。但是在更改 Revit 视图(或几何图形)后,它会抛出错误。

这就是我们实现 LevelsExtension 的方式:

const initViewer = () => {
    return new Promise((resolve, reject) => {
        var options = {
            env: 'AutodeskProduction2',
            api: 'derivativeV2_EU',
            getAccessToken,
        };

        Autodesk.Viewing.Initializer(options, () => {
            const config = {
                extensions: [
                    'Autodesk.DocumentBrowser',
                    'Autodesk.AEC.LevelsExtension',
                ],
            };

            const container = document.getElementById('viewer');

            const viewer = new Autodesk.Viewing.GuiViewer3D(
                container,
                config
            );

            viewer.start();

            resolve(viewer);
        });
    });
};

const loadModel = (viewer, model, index) => {
    const onDocumentLoadSuccess = (doc) => {
        const geometries = doc.getRoot().search({ type: 'geometry' });

        doc.downloadAecModelData();

        viewer.loadDocumentNode(doc, geometries[index], {
            createWireframe: false,
            applyScaling: 'm',
            isAEC: true,
        });
    };

    Autodesk.Viewing.Document.load(
        'urn:' + model.urn,
        onDocumentLoadSuccess,
        onDocumentLoadFailure
    );
};

正如您在更改视图之前所看到的,级别面板有一个

div
id="LevelsPanel-0"

但是更改视图后,将会添加另一个面板,而不会终止前一个面板(如您所见,前一个面板仍然打开):

如果您将鼠标悬停在上一个打开的面板上,它将抛出以下错误:

autodesk-forge autodesk-viewer revit-api
1个回答
0
投票

感谢您的详细信息。即使不使用您的代码,我也可以重现此问题。我向我们的工程团队报告以获得见解。对于给您带来的不便,我们深表歉意!

这里有一个解决方法,我们在加载新模型之前删除levelsPanel。

viewer.getExtension('Autodesk.AEC.LevelsExtension').levelsPanel?.setVisible(false);
viewer.getExtension('Autodesk.AEC.LevelsExtension').levelsPanel?.container.remove();

完整代码

    const loadModel = (viewer, model, index) => {
      const onDocumentLoadSuccess = async (doc) => {
        if (viewer.getExtension('Autodesk.AEC.LevelsExtension')) {
          viewer.getExtension('Autodesk.AEC.LevelsExtension').levelsPanel?.setVisible(false);
          viewer.getExtension('Autodesk.AEC.LevelsExtension').levelsPanel?.container.remove();
        }
        
        const geometries = doc.getRoot().search({ type: 'geometry' });

        doc.downloadAecModelData();

        viewer.loadDocumentNode(doc, geometries[index], {
          createWireframe: false,
          applyScaling: 'm',
          isAEC: true,
        });
      };

      onDocumentLoadFailure = (error) => console.error(error);

      Autodesk.Viewing.Document.load(
        'urn:' + model.urn,
        onDocumentLoadSuccess,
        onDocumentLoadFailure
      );
    };
© www.soinside.com 2019 - 2024. All rights reserved.