Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
379 views
in Technique[技术] by (71.8m points)

javascript - Zooming Asset in Forge Viewer While selecting the asset from Tree menu

  1. We have implemented the Forge Viewer in our web application to display the REVIT files. For this we have used the code available in the below link. https://forge.autodesk.com/blog/forge-aspnet-zero-hero-30-minutes

    We have used the below code in aspx page.

    var viewer; var urn1; var accestoken1; var jsdata; function showModel(urn) { alert('showModel'); var options = { env: 'AutodeskProduction', getAccessToken: getForgeToken };
          Autodesk.Viewing.Initializer(options, () => {
              viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'), { extensions: ['Autodesk.DocumentBrowser'] });
              viewer.start();
              var documentId = 'urn:' + urn;
              urn1 = urn;            
              Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);   
          });
      }
    
      function onDocumentLoadSuccess(doc) {
          this.viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, (x) => {
          });
          var viewables = doc.getRoot().getDefaultGeometry();
          viewer.loadDocumentNode(doc, viewables).then(i => {
          });
      }
    
    1. Also We have extracted assets from REVIT file and store it in our external database(SQL database). For extracting assets we have used the below API. https://developer.api.autodesk.com/modelderivative/v2/designdata/" + objectIdBase64 + "/metadata/" + userGuid + "/properties

    The above 2 points are working fine. but we are not able to zoom the selected asset from asset tree. We need sample code for the below questions:

    Question 1: how to zoom the selected asset in forge viewer by clicking on the asset from tree? Please provide working source code for this.

    Question 2: We have searched some links they suggested to use FittoView() funvtion by passing the dbid as a parameter to zoom the asset. But while we extracting the asset from API, we did not get the dbid in JSON result. we are getting ExternalID only. Please let us know how to use the FittoView() in javascript and how to get the dbid while extracting assets from above API call.

    Thank you in advance.

question from:https://stackoverflow.com/questions/65840471/zooming-asset-in-forge-viewer-while-selecting-the-asset-from-tree-menu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...