I have couple of questions about combine model on forge viewer (load list urn to 1 viewer):
var instanceTree = GlobalViewer.model.getData().instanceTree;
var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
var list = allDbIdsStr.map(function (id) { return parseInt(id) });
list will return all dbid of main model, how can i access all data of all model when i combine?Appreciate any comments,
Regarding #1: viewer.model
obviously only references one of the models (I believe it's the last one you loaded), but you can use viewer.getVisibleModels()
or viewer.getHiddenModels()
to get other loaded models as well.
Regarding #2: dbIDs
are only unique within a single model; many of the viewer methods accept an additional parameter specifying the model on which to operate, for example, you could say viewer.select([123, 456], oneOfMyModels)
.
Regarding #3: that's a good question; loading a 2D model first puts the viewer into 2D viewing mode (where only zoom and pan is allowed); if you know you will be working with 3D models, I'd recommend always loading those first
Regarding #4: yes, each loaded model can have different units; when loading a model using the loadDocumentNode
method you can specify additional options (for example, a placement transform for the loaded geometries), and one of them is an object called applyScaling
, for example, like so:
viewer.loadDocumentNode(doc, viewable, {
applyScaling: { to: 'mm' }
});