September 21, 2018

Enumerate dbIds on 2D views

Default blog image

Some 2D views of documents will not have the InstanceTree, if you try to enumerate leaf nodes you will get F2D files do not have an InstanceTree error.

The alternative is to use the fragmentId to dbId mapping, the following code shows the idea for Viewer v6:

var frags = _viewer.model.getFragmentList().fragments.fragId2dbId;
frags.forEach(function(frag){
  frag.forEach(function(dbId){
    if (dbId<0) return;
    // do something with the dbId
  });
});

One interesting application is to use .setThemingColor, which requires the dbId.

Related Posts