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.
According to our BIM360 user manul here, the Crop View checkbox enabled is required.
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);