Querying Models and Objects

This page describes how to find the IDs of the models and objects that you have loaded in your viewer. Once you have those IDs, you can then access properties of the models and objects, to do things like query their boundaries or set their visibilities.

As described in Loading Models, when we load a model, we assign it a unique ID. Each object loaded in the model also gets a unique ID that's prefixed by the model's ID, Eg. "<model ID>#<object ID>". This lets us load multiple copies of the same models, without getting ID conflicts between the objects.

Each object corresponds to a node element within its model's glTF file. If the node has a name attribute, then that's used for the object part of the ID, eg. "saw#outerCasing". Otherwise, the index of the node within the glTF file's nodes section is used, eg. "saw#23".


Getting the IDs of all models in a viewer:

var modelIds = viewer.getModels();
// Eg. ["saw", "house"]

Getting all objects in a viewer:

var objectIds = viewer.getObjects();
// Eg. ["saw#1", "saw#1.2", "saw#2", "house#12", "house#23", ...]

Note how each ID is prefixed with the ID of its object's model.

Getting all objects in a model:

var sawObjectIDs = viewer.getObjects("saw");
// Eg. ["saw#1", "saw#1.2", "saw#2", ...]

Getting an object's model:

var modelId = viewer.getModel("saw#23");
// Returns "saw"

Getting all objects of the given types (see Assigning types to objects):

var flowObjectIds = viewer.getObjects(["IfcFlowController", "IfcFlowFitting"]);
// Eg. ["house#12", "house#23"]

results matching ""

    No results matching ""