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.
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 => { }); }
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.
1.4m articles
1.4m replys
5 comments
56.9k users