title: How to get all the DB-IDs in Autodesk Forge
body: <p>I need to get all the DB-Ids from the Autodesk forge  model. I have referred the code from <a href="https://forge.autodesk.com/cloud_and_mobile/2015/12/select-all-elements-in-the-viewer-with-view-and-data-api-with-javascript.html" rel="nofollow noreferrer">https://forge.autodesk.com/cloud_and_mobile/2015/12/select-all-elements-in-the-viewer-with-view-and-data-api-with-javascript.html</a></p>
  
  <p>I also have tried it in my own extension and the code is as follows.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>AutodeskNamespace("Autodesk.ADN.Viewing.Extension");
  Autodesk.ADN.Viewing.Extension.Color = function(viewer, options) {
  
    Autodesk.Viewing.Extension.call(this, viewer, options);
    var _self = this;
  
    var _viewer = viewer;
    var instanceTree = viewer.model.getData().instanceTree;
  
    var rootId = this.rootId = instanceTree.getRootId();
    _self.load = function() {
      getgetAlldbIds(rootId);
    };
  
    function getAlldbIds(rootId) {
      var alldbId = [];
      if (!rootId) {
        return alldbId;
      }
      var queue = [];
      queue.push(rootId);
      while (queue.length &gt; 0) {
        var node = queue.shift();
        alldbId.push(node);
        instanceTree.enumNodeChildren(node, function(childrenIds) {
          queue.push(childrenIds);
        });
      }
      console.log(alldbId);
    }
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I'm getting an error in Developer Tools as <code>cannot read property 'getData' of null</code> where do you think I'm going wrong. thanks in advance.</p>