1

I am building an application around Autodesk Forge Viewer, where I add extra functionalities using basic functions from Viewer (coloring, isolating etc.) depending on client data.

This application also allows you to upload a new model. After the upload and conversion process, metadata is extracted from the model using this Model Derivative API https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-metadata-guid-GET/, which basically returns the tree of objects and their ids/names.

On the viewer side, all the basic interaction functions like setThemingColor, show, hide, isolate etc. requires dbIds as a parameter. To avoid multiple search requests to find out the dbId of an item, which would cause a huge performance problem as the model size is above average, dbIds are retrieved from the metadata on the BE side and provided to FE to for the coloring or a similar operation requiring only dbids to execute.

However, recently I discovered that objectid from Model Derivative API metadata and dbId required in the Viewer functions are not matching. How does these two fields correlate to each other, are they supposed to be the same or not? If not, is there a way of converting one into another?

I couldn't find any official/unofficial documentation about this, any help is appreciated.

Berk Kurkcuoglu
  • 1,453
  • 1
  • 9
  • 11

1 Answers1

2

The objectids from the Model Derivative APIs and the dbids in the viewer (coming from the SVF file format) should always match. The only exception is the new SVF2 format (which has just entered public beta) where the dbids are computed in a different way in order to be "stable", as in, "consistent across different versions of the same design".

To be on the safe side, you could link the design elements with your metadata using the "external ID" which is guaranteed to be consistent. On the client side you can use the viewer.model.getExternalIdMapping(onSuccessCallback, onErrorCallback) method to get a dictionary mapping from external IDs to dbids.

Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • Hi Petr, thanks for the quick response, I guess we'll proceed with the second approach since we are using svf2. Is there a way of retrieving only the externalIds from model derivative API? I've tried GET :urn/metadata/:guid/properties request but it also adds property information as well, which adds up too much to the file size, I couldn't find any query params or similar to avoid that, thanks. – Berk Kurkcuoglu Oct 23 '20 at 08:49
  • I'm afraid the MD API doesn't support any kind of filtering. Note however that there are different ways of obtaining the metadata without the viewer, not just using the MD endpoint. See my blog post: https://forge.autodesk.com/blog/accessing-design-metadata-without-viewer. – Petr Broz Oct 23 '20 at 09:10