Search code examples
autodesk-forge

Some models loaded in a forge viewer do not return any viewport


I have a forge viewer loading a document with multiple viewables from a Revit project in BIM360. I can see all viewables rendered just fine. I'm using Autodesk.AEC.ViewportsExtension to display certain elements on the viewer at specific locations, e.g. tags. I managed to successfully show tags by following a blog post by Petr, but some viewer models fail to return any viewport.

    viewportExt = viewer.getExtension("Autodesk.AEC.ViewportsExtension");
    viewport = viewportExt.getViewports(viewer.model)[0]; // this returns null
    viewportXform = viewport.get3DTo2DMatrix(viewer.model.getUnitScale());

this works for some viewables but some don't return any viewports which I need, to translate between 3D and 2D spaces. I can see AEC metadata is loaded in both cases. I am at a loss why only certain views fail to return viewports.


I just tried Petr's sample with my own models in BIM360. My viewables from the Revit projects are not returning any viewports. I suspect this has something to do with what's happening during BIM 360 publish process.

Any advice would be greatly appreciated.


Solution

  • According to our BIM360 user manul here, the Crop View checkbox enabled is required.

    • Newly published data. It does not work for previously published models.
    • 2D sheets with floor plan views, structural plan views, or reflected ceiling plan views. Other sheets with callout or area plan views are not supported currently.
    • Sheets with the Crop View checkbox enabled in Revit.
    • Views without view breaks. Views containing view breaks or view splits are not supported currently.
    • Views don't have Plan Regions associated. We can check this by using the following code snippet using Revit API
    var planRegion = new FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_PlanRegion).ToList();
    
    planRegion.Any(r => r.OwnerViewId.Value() == planView.Id.Value());
    
    //Before 2024
    //planRegion.Any(r => r.OwnerViewId.IntegerValue == planView.Id.IntegerValue);