【问题标题】:How do I get my autodesk extension to appear?如何让我的 Autodesk 扩展出现?
【发布时间】:2021-11-25 15:15:34
【问题描述】:

在 Autodesk 教程的这一步遇到问题,ForgeTree 和 ForgeViewer 工作得很好,但我根本无法让 handleselectionextension 工作,没有菜单或工具栏只显示一个空窗口

https://learnforge.autodesk.io/#/viewer/extensions/selection

main.css

.handleSelectionExtensionIcon {
    background-image: url(https://github.com/encharm/Font-Awesome-SVG-PNG/raw/master/white/png/24/object-group.png);
    background-size: 24px;
    background-repeat: no-repeat;
    background-position: center;
}

index.html

<!-- this project files -->
  <link href="css/main.css" rel="stylesheet" />
  <script src="js/ForgeTree.js"></script>
  <script src="js/ForgeViewer.js"></script>
  
  <script src="js/handleselectionextension.js"></script>

扩展只是教程中展示的那个

【问题讨论】:

    标签: autodesk-forge


    【解决方案1】:

    您必须在 Forge 查看器中加载扩展。

    viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'), { extensions: ['HandleSelectionExtension'] });
    

    之后,您可以在单击按钮上调用以下代码来隔离选定的对象。

    // Get current selection
    const selection = this.viewer.getSelection();
    this.viewer.clearSelection();
    // Anything selected?
    if (selection.length > 0) {
        let isolated = [];
        // Iterate through the list of selected dbIds
        selection.forEach((dbId) => {
            // Get properties of each dbId
            this.viewer.getProperties(dbId, (props) => {
                // Output properties to console
                console.log(props);
                // Ask if want to isolate
                if (confirm(`Isolate ${props.name} (${props.externalId})?`)) {
                    isolated.push(dbId);
                    this.viewer.isolate(isolated);
                }
            });
        });
    } else {
        // If nothing selected, restore
        this.viewer.isolate(0);
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      • 2020-08-03
      • 2022-11-10
      • 2020-10-30
      • 1970-01-01
      • 2021-03-19
      相关资源
      最近更新 更多