21 Sep 2023

No room information in Revit file when working with DataViz extension in Viewer?

Default blog image

When using Data Visualization extension in the Viewer you often encounter the issue of no room information in the translated Revit file, that's because it requires a special case of translation. As mentioned in the documentation under Case 6 - Input file type is RVT:

formats->advanced->generateMasterViews should be set to true to get the room information, by default it is false, if you plan to use the Data Visualization extension and need the room information, this should be set to true when translating. This is the JSON body for translation:

{
  "input": {
    "urn": "<<URN>>"
  },
  "output": {
    "formats": [
      {
        "type": "svf",
        "views": [
          "2d",
          "3d"
        ],
        "advanced":{
          "generateMasterViews":true
        }
      }
    ]
  }
}

Note: We don’t need to request master view translation on Revit files from ACC/BIM360 ourselves, as ACC/BIM360 translates master views for Revit files by default. This applies to Revit files uploaded to OSS only.

Once the translation is successful, on the front end side, ensure to load Revit master views, as Revit Rooms are visible only in the master views (ref). Or load rooms as a second model by selective loading and pass the model containing rooms to DataViz ext. You can load the masterview in viewer by either of these two methods:

// Method 1:
const root = viewerDocument.getRoot() ;
const viewables = root.search({'type': 'geometry', 'role': '3d'});
console.log ('Viewables:' , viewables);
const phaseViews = viewables.filter (v => v.data.name === v.data.phaseNames
&& v.getViewableRootPath().includes('08f99ae5-b8be-4f8d-881b-128675723c10'));  // pass the guid
console.log('Master Views:', phaseViews);

// Method 2: if you just have one master view (phase) inside your model.
viewerDocument.getRoot().getDefaultGeometry(true);

After that, you can get the room information on the front end side using the following code:

let roomids;
viewer.search('Revit Rooms',
    ids => { roomids=ids },
    err => { console.error(err); },
    ['Category'], { searchHidden: true 
});

roomids.forEach((id)=>{viewer.model.getProperties(id, (p) => {
     console.log(p);
    });
})

 

 

Related Article