Search code examples
autodesk-forgeautodesk-viewerrevit

Forge Viewer loading multiple Revit models with shared coordinates


When loading Revit models which are aligned by shared coordinates, the models does not align in Forge Viewer with globallOffset settings.

The loadModel with placementTransform option seems to be viable, but the shared coordinates data is not made available until after the model is loaded, via viewer.model.getDocumentNode().getAecModelData().refPointTransformation

earliest I have the model data is inside the onLoadModelSuccess which is too late to feed into the load options, and will require to transform the geometries.

var modelOptions = {
  sharedPropertyDbPath: doc.getPropertyDbPath(),
  globalOffset: offset,
  placementTranform: ???,
  isAEC: true
};

viewer.loadModel(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);

How would it be possible to align the models otherwise? Or maybe to load the model without rendering the geometry first to get the data then feed the transform matrix into another loadModel call?


Solution

  • Use the following two options together to apply Revit shared coords:

    • globalOffset - tells LMV not to auto centre model
    • applyRefPoint - tells LMV how to apply any svf positioning meta-data for Revit files

    So try the below in your load options:

    var modelOptions = {
      sharedPropertyDbPath: doc.getPropertyDbPath(),
      globalOffset: offset,
      applyRefPoint: true,
      isAEC: true
    };
    

    And see this live sample here for usage reference on the placementTranform option.