How does autodesk forge get the file tree of model browser functionality?

1. The official has the function of viewing the file tree, that is, the file tree of the model browser. What is the api for getting this file tree?


you can get the component tree in the following ways:

var it = viewer.model.getData().instanceTree;

//
viewer.getObjectTree(function( instanceTree ) {
   console.log( instanceTree );
});

due to data optimization, all data are flattened. To reconstruct the data structure, you can use:

function buildModelTree( model ) {

    //builds model tree recursively
   function _buildModelTreeRec( node ) {
         it.enumNodeChildren( node.dbId, function(childId) {
                 node.children = node.children || [];

                 var childNode = {
                   dbId: childId,
                   name: it.getNodeName( childId )
                 };

                 node.children.push( childNode );

                 _buildModelTreeRec( childNode );
           });

   }

   //get model instance tree and root component
   var it = model.getData().instanceTree;

   var rootId = it.getRootId();

   var rootNode = {
         dbId: rootId,
         name: it.getNodeName( rootId )
   };

   _buildModelTreeRec( rootNode );

   return rootNode;
 }

 var root = buildModelTree( viewer.model );
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb1441-4f811.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb1441-4f811.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?