20 Feb 2020

add Revit Levels and 2D Minimap to your 3D

Do you want to provide a small 2D 'mini-map' as a pop up dialog in your forge viewer ?

Thankfully, the BIM360 team have already coded it as an extension !

 

UPDATES:

- added AECModelData.json section below

- for IFC files, you can enable levels using { ifcLevelsEnabled: true } option: https://forge.autodesk.com/en/docs/viewer/v7/change_history/changelog_v7/#id42

 

Introduction:

This extension requires a little bit of extra 'level' information, to make it work.  That's the data that describes the buildings height, from floor to ceiling, for each level of the building.  It needs that info to 'crop' to that particular level.

For example,

Say, we wanted to see a top-view of just the 4th floor inside a sky-scraper design:

"We would use the section box tool, and manually crop to the ceiling and floor of the 4th floor" and finally, move the camera to a 'top view'.

For the mini-map tool to do this automatically, it's needs that level information, which is found in the special 'AECModelData.json' file, which Xiaodong's blog post mentions.  This special file was automatically generated for Revit files, when using forge model derivative services, starting as of May 2019.
 

Steps

1. using Forge Derivative Services, convert your Revit file to SVF
(make sure the AECModelData.json is created after May 2019)

2. In Forge-Viewer, use doc.downloadAecModelData() to load the AECModelData.json

3. load the extensions "Autodesk.AEC.LevelsExtension" and "Autodesk.AEC.Minimap3DExtension"

4. switch to 'walkthrough' mode - viewer.getExtension("Autodesk.BimWalk").activate();

 

Example

To see steps 2 and 3 in action, here's some example code that loads the right extensions, and loads the aecmodeldata.json file:

Autodesk.Viewing.Initializer(options, () => {

        const div = document.getElementById('forgeViewer');

        const config = { extensions:[ 
          "Autodesk.AEC.LevelsExtension", 
          "Autodesk.AEC.Minimap3DExtension"
        ]};

        viewer = new Autodesk.Viewing.Private.GuiViewer3D(div, config);
        viewer.start();
        Autodesk.Viewing.Document.load(`urn:${urn}`, (doc) => {
            var viewables = doc.getRoot().getDefaultGeometry();
            doc.downloadAecModelData();
            viewer.loadDocumentNode(doc, viewables).then( onLoadFinished );

            viewer.addEventListener( Autodesk.Viewing.TEXTURES_LOADED_EVENT, ()=>{
                viewer.getExtension("Autodesk.BimWalk").activate();
            });
        });



etc...

 

And here's the result...

LIVE DEMO: https://wallabyway.github.io/forge-pinch-zoom/minimap.html

minimap

 

Follow me on Twitter for other cool tricks:  @micbeale

Update:

AECModelData.json and globalOffset info:

This is typically what the AECModelData.json file looks like,

You can see there is a 'levels' section that contains the elevation and height.  This is used to maneuver the built-in section box (on the toolbar).

{
    "version": "1.0.0",
    "documentId": "db9ca3e5-def6-4cbe-8dd4-0474db1c1903",
    "phases": [{
        "name": "Existing"
    }, {
        "name": "New Construction"
    }],
    "levels": [{
        "guid": "4a6fb374-4b76-46df-b01c-9fe11681ff2d-0004d3da",
        "name": "Piano Terra_Level  -4.62",
        "elevation": -15.15748031496063,
        "height": 5.7742782152230969,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "79503529-d2a7-11d3-9162-0000863f27ad-0000330f",
        "name": "Level CAD -2.86",
        "elevation": -9.3832020997375327,
        "height": 9.3832020997375327,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "67406d4d-fc88-4216-b154-c7d018edc97c-00039e47",
        "name": "Primo Piano_Level  +0.00",
        "elevation": 0.0,
        "height": 4.8884514435695534,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "44bd8488-e63e-11d3-918b-0000863f27ad-00003e29",
        "name": "Level CAD +1.49",
        "elevation": 4.8884514435695534,
        "height": 20.111548556430446,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "9da2b333-4a50-4114-ab17-59e5f1f5e812-00058029",
        "name": "Secondo Piano_Level  +7.62",
        "elevation": 25.0,
        "height": 12.040682414698161,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "9da2b333-4a50-4114-ab17-59e5f1f5e812-0005813f",
        "name": "Terzo Piano_Level  +11.29",
        "elevation": 37.040682414698161,
        "height": 9.3175853018372621,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "9da2b333-4a50-4114-ab17-59e5f1f5e812-00058095",
        "name": "Sottotetto_Level  +14.13",
        "elevation": 46.358267716535423,
        "height": 15.223097112860899,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }, {
        "guid": "e0b7296a-e467-46b1-9aa5-dfcd22bddbea-0005f540",
        "name": "Sottotetto_Level  +18.77",
        "elevation": 61.581364829396321,
        "height": 2147483647.0,
        "extension": {
            "buildingStory": true,
            "structure": false,
            "computationHeight": 0.0,
            "groundPlane": false,
            "hasAssociatedViewPlans": true
        }
    }],
    "scopeBoxes": [],
    "refPointTransformation": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
    "levelOccluderIds": [3472, 3492, 3505, 3551, 3638, 3710, 3743, 3784, 3823, 3857, 3893, 3910, 3935, 3956, 3987, 4004, 4018, 4024, 4052, 4071, 4083, 4136, 4213, 4225, 4236, 4250, 4261, 4274, 4289, 4306, 4320, 4328, 4338, 4348, 4355, 4362, 4590, 4625, 4641, 4648, 4669, 4690, 4707, 4735, 4753, 4774, 4781, 4835, 4849, 4899, 5013, 5028, 5047, 5109, 5123, 5136, 5548, 5578, 5672, 5688, 5721, 5738, 5754, 5770, 5787, 5803, 6105, 6128, 6170, 6228, 6292, 6485, 6499, 6519, 6549, 6570, 6581, 6607],
    "viewports": [],
    "grids": [],
    "linkedDocuments": [],
    "locationParameters": {
        "placeName": "Boston, MA"
    }
}

 

 

To pull this file AECModelData.json directly...

  1. open Chrome Debugger
  2. filter on AECModelData.json
  3. double click on the URL to open and inspect
  4. re-use this URL (with access-token) to pull this information into your own custom database

Note, the refPointTransformation (above) can provide the globalOffset value.  You can load file AECModelData.json, before starting Forge-Viewer.  Do this when you are multi-model loading a bunch of NWD/RVT files (say, infrastructure projects with a large offset).  See this  stack overflow issue for details.

 

aecdata-debug

 

 

Related Article