'How to aggregate 2D documents in Forge viewer?

I would like to aggregate multiple 2D sheets within same scene of Forge viewer. Testing with the legendary "Office" model so it's easy for you to reproduce. When loading sheet1 everything is ok, when loading a second sheet the sheet itself completely overlap the sheet1 so none of the entities on sheet1 are visible any more. Any workaround for that?

Yes, I am using the keepCurrentModels: true:

const loadOptions = {
  keepCurrentModels: true,
  preserveView: true
}

viewer.loadDocumentNode(doc, viewable, loadOptions)

enter image description here

enter image description here



Solution 1:[1]

(ie. from tip#4 above)

To overlay 2 different sheets on top of each other, using the two sheets example above, see the image below and this code snippet:

Use the model browser to hide/show each layer (in the image, there are two models):

            view.viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, target => {

              if (target.model.id > 1)
                target.model.getFragmentList().vizflags[0] = 0;
            })

2 sheets overlay

Notes:

To make everything 'selectable', do the following:

  1. add white 'empty' 2D sheet, as backdrop
  2. add all other sheets on top
  3. set each sheet's vizFlags[0]=0, except for the 'empty' sheet

Blog post coming! ;-)

Solution 2:[2]

Unfortunately as things were before it is not yet possible to aggregate 2D sheets with Viewer so as a workaround you’d need to made do with multiple Viewer instances in parallel on one page and try achieve overlapping with CSS settings (which is a bit hacky obviously this approach has its limitations as the geometry and events wouldn’t get aggregated)

Viewer might support this going forward so stay tuned to our official blog for updates.

P.S.: Michael Beale is putting together a blog on the aggregatedView tool to support fast switching between sheets so stay tuned.

Solution 3:[3]

I have three tips for multi-model. I'm writing a blog post on it.

The first tip: To get side-by-side-2d-sheets, I changed the placementTransform in the options3D.

side-by-side-2d-sheets

placement transform notes: https://forge.autodesk.com/blog/loading-multiple-models-forge-viewer-v7

For the gif above, I switched over to using AggregateView Class. It's seems like it could be a cleaner API for handling multi-models in the future.

Additional multi-model Tips

(coming in a new blog post, soon):

Tip 2. Hypermodeling - combining 3D models and 2D sheets inside the 3D scene

hypermodeling

Tip 3. Fast view-switching (between 2D sheets)

Tip 4. Hiding the white background of a 2D sheet (used mostly when compositing inside a 3D scene).

Notes: To blend background image, would you be looking for tip#4 ?

Solution 4:[4]

Did you try modelSpace:true in the options ?

let options = { placementTransform: new window.THREE.Matrix4(), modelSpace: true, globalOffset: { x: 0, y: 0, z: 0 }, applyRefPoint: true, isAEC: true, // to align the models, }

More details here:

Autodesk forge viewer api v7.* align multiple 2d dwg models

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Bryan Huang
Solution 3
Solution 4 michael beale