21 Mar 2019

Simulate empty view in the Forge Viewer

 

A while ago, I got a request from our Forge viewer users about initializing a viewer without loading any model. Basically, it's impossible to use the viewer in that way currently since some viewer configurations are determined during the load process as I know. However, I provided a workaround to the empty viewer thread on the StackOverflow. To simulate it, we can do something like this:

Loading a dummy model that contains very very tiny points like the maximum and minimum points of a bounding box to make it look like there is no model loaded. Before loading new models, you have to unload this dummy model firstly and call Viewer3D.tearDown() to release some used memories.

 

Now let's see how to achieve it. The following steps take advantages of the Revit generic family template and 3D view bounding box.

 

1. We have to create a Ghost Point family to represent the very very tiny points mentioned above, here is its look like:

Ghost Sphere RFA

 

2. Place two instances of this Ghost Point family to somewhere very close to both the maximum point and the minimum point of the default Revit 3D view bounding box like below.

Ghost Spheres on Maximum Extents

To simply the work, I wrote a Dynamo script to speed this up:

Ghost Sphere Placement

 

Then adjust the offsets of these two ghost points to +30000 (the maximum point) and -30000 (the minimum point) from my trial and error. (If these two points are too closed to the maximum point or minimum point the view bounding box, they will disappear after Forge translation with my tests.)

 

3. Upload this Revit project to Forge server for translation and open it with the viewer as usual, and you will see a simulated empty view in the viewer. Here is the demo video:

 

 

Enjoy it! For more code details, please check source codes and sample mode here: https://github.com/yiskang/forge-empty-viewer-poc

Related Article