简体   繁体   中英

Select particular 3d view to show in autodesk forge viewer

Is there a way to show and select from multiple 3d views using autodesk forge api which has already been uploaded to BIM 360 docs?

It is possible to show a BIM360 docs model on your WEB page. There is nice tutorial which shows you how to proceed - If your question is about showing multiple views on the same page, you will need to start 2 (or more) viewers and change the viewableID you want to see from the model. To do this, you will need the change the code to list and switch the viewableID.

Tutorial code which loads views.

// if a viewableId was specified, load that view, otherwise the default view
var viewables = (viewableId ? doc.getRoot().findByGuid(viewableId) : doc.getRoot().getDefaultGeometry());

doc.getRoot().getDefaultGeometry() will load the default view. The one which was active when you saved the original seed file.

doc.getRoot().findByGuid(viewableId) - find a view based on its GUID. GUIDs can be retrieved from the manifest since all 3d and 2d views are listed in the model manifest.

doc.getRoot().find({ role: '3d', type: 'geometry' }) will return a list of 3d views from the model (replace 3d by 2d for listing the 2D views)

Note, you can load the Autodesk.DocumentBrowser extension to navigate to any views within the Viewer without coding.

const viewables = doc.getRoot().find({ role: '3d', type: 'geometry' }) throws error saying 'Uncaught TypeError: doc.getRoot(...).find is not a function'.

I had to do replace 'find' with 'search' to fix this

const viewables = doc.getRoot().search(
    {
      type: "geometry",
      role: "3d",
    },
    true
  );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM