Enumerate dbIds on 2D views

September 21, 2018

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.

Posts by author

Augusto Goncalves
Developer Advocate, Autodesk

Developer Advocate at Autodesk since 2008, working with both desktop and web/cloud apps using top technologies, like C#, JavaScript, NodeJS and any other that can solve problems and improve workflo