autodesk-tandem

How to filter model views and retrieve data in the embedded Tandem Viewer?


After successfully initializing and starting the Autodesk Tandem Viewer, I can load and display the entire model. Based on a previous REST API call and user selection, I receive a twinId and a viewId.

Question 1: How can I display only the view (associated with the sViewId), not the entire model?

Question 2: How can I retrieve the data associated with the view (e.g., like the inventory table shown in the Tandem Application)?

Below is the relevant part of my current implementation:

displayFacility: function (sTwin, sViewId) {
  const app = this.oApp;
  return new Promise((resolve, reject) => {
    app.getCurrentTeamsFacilities()
      .then((facilitiesSharedWithMe) => {
        app.getUsersFacilities()
          .then((myFacilities) => {
            const aFacilities = [].concat(facilitiesSharedWithMe, myFacilities);
            const matchingFacility = aFacilities.find(facility => facility.twinId === sTwin);
            if (!matchingFacility) {
              const msg = `Facility with twinId '${sTwin}' not found.`;
              console.error(msg);
              reject(new Error(msg));
              return;
            }
            const currentFacility = app.displayFacility(matchingFacility, false, this.oViewer);
            resolve();
          });
      });
  });
}

Solution

  • To display specific view use logic shown in this example. It basically calls app.views.setCurrentView using facility and view as input.

    The inventory is showing data for displayed elements. So you would need to get dbIds of displayed elements and then use DtModel.getPropertiesDt to get properties of each element. To get visible elements use DtModel.getVisibleDbIds(). Note that facility can have multiple models so you need to do it for each model. To get list of models use DtFacility.modelsList.