0

Ideally, while in viewer, goal would be to load/unload linked model in the viewer. This way, different engineering layers (structure/water/electricity/...) can be shown/hidden at will.

For this, I tried several options, but none is completely suited (up to my knowledge).

Whatever the solution, is there a way to unload a model/link in viewer?

Thank you

Fabien
  • 41
  • 7

1 Answers1

0

About the model aggregation in Revit models, you might take a wrong alignment setting.

Commonly, Forge viewer put the loaded model with a global offset of the center of models' bounding box by default. So, all models loaded after the 1st must be set up with the same globalOffset of the 1st model, here is the code snippet for global offset alignment I answered here.

function _onGeometryLoaded( event ) {
   if( urns.length <= 0 ) {
       viewer.removeEventListener(
         Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
         _onGeometryLoaded
       );
       return;
   }

   viewer.loadModel( urns[0], { globalOffset: event.model.getData().globalOffset } );
   urns.splice( 0, 1 );
 }

 viewer.addEventListener(
   Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
   _onGeometryLoaded
 );

 viewer.loadModel( urns[0] );
 urns.splice( 0, 1 );

For Revit models with shared coordinates, you can load models in this way, see here for details.

var loadOptions = {
  applyRefPoint: true,
  globalOffset: { x:0, y:0, z:0 }
};

viewer.loadModel(
            svfUrl, 
            loadOptions,
            onLoadModelSuccess,
            onLoadModelError
);
Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • Thanks for feedback. After getting deeper into previous here are few limitations I found, can you tell me if they are way to solve them: 1-When loading rvt models and links from-a-zip/Post-references, in tree, we see only a single model. Is it possible to keep models of links separated? 2-When loading multiple models, all is fine, but when unloading a model, sometimes ok, sometimes, all models are unloaded from scene? it is known? – Fabien Aug 29 '18 at 13:54
  • For the 1st, all models in the zip will translate into single model, it’s not the same as you saw in the Navisworks. – Eason Kang Aug 29 '18 at 13:59
  • About the 2nd, that depends on which viewer api that you called, but I didn’t see any info. about this part in your question, so I can’t tell what happened. Could you share your code snippets above? – Eason Kang Aug 29 '18 at 14:02
  • 2- NOP_VIEWER.impl.unloadModel(modelArray[0].modelObj) is what I use to unload model. – Fabien Aug 30 '18 at 07:50
  • In 1st, the InstanceTree of all linked Revit files will be merged into the host RVT after Forge translation, so you won’t see the same model structure hierarchy in the Navisworks. That’s what I mean for the above, sorry for confusion. – Eason Kang Aug 30 '18 at 08:00
  • For the 2nd, that’s not expected behavior with my experience. Could you consider providing a non-confidential reproducible case with your detail question descriptions, simplest models and minimize Forge app that demonstrating this issue to forge.help@autodesk.com? – Eason Kang Aug 30 '18 at 08:05
  • With my investigation on your test case, I found that it might be a model structure panel issue, models didn't disappear from the scene after unloading a specific model. Please check my reply in email. – Eason Kang Aug 30 '18 at 16:07
  • We have logged a request, `LMV-3703`, to our engineering team to allocate time to investigate the model tree disappeared issue on the model structure panel. please remember the request id (LMV prefixed string) for future reference. You're welcome to check updates or provide additional information via sending an email quoting the request id to Forge Helpdesk. – Eason Kang Aug 31 '18 at 02:21