首页 > 解决方案 > Forge 查看器 6.3.4 版不显示新发布的文档浏览器扩展

问题描述

我将解决方案的 forge 查看器版本升级到 6.*,以利用此处提到的最新发布的功能“文档浏览器扩展”

我没有显示此扩展程序,请帮助。

标签: autodesk-forgeautodesk-viewer

解决方案


经过一些实验,我得到了它的工作。这是我的工作流程,以防您仍然需要它。

首先,初始化查看器:

// initialize the viewer
Autodesk.Viewing.Initializer(adOptions, () => {
  // when initialized, call loading function
  this.loadDocument(encodedUrn);
});

然后,在上面调用的函数中加载您的文档:

// load the document from the urn
Autodesk.Viewing.Document.load(
  encodedUrn,
  this.onDocumentLoadSuccess,
  this.onDocumentLoadFailure,
);

在成功回调中,您现在可以执行以下操作:

onDocumentLoadSuccess(doc) {
  // get the geometries of the document
  const geometries = doc.getRoot().search({ type: 'geometry' });

  // Choose any of the available geometries
  const initGeom = geometries[0];

  // and prepare config for the viewer application
  const config = {
    extensions: ['Autodesk.DocumentBrowser'],
  };

  // create the viewer application and bind the reference of the viewerContainer to 'this.viewer'
  this.viewer = new Autodesk.Viewing.Private.GuiViewer3D(
    this.viewerContainer,
    config,
  );

  // start the viewer
  this.viewer.start();

  // load a node in the fetched document
  this.viewer.loadDocumentNode(doc.getRoot().lmvDocument, initGeom);
}

我希望这也能让它对你有用。帮助我的是这篇博文中对 loadDocumentNode 函数的引用。


推荐阅读