GhostOsiris
GhostOsiris

Reputation: 3

A360 viewer: Fetching object properties for web application integration

I am trying to integrate the autodesk a360 viewer into my web application. However, we'll like to extract the object properties of the selected object to fetch additional information from within our database. For example, when user clicks on a door, we wan to extract the tag id of this door from the object properties and perform some sql query with this tag id.

I've seen autodesk forge, but it i m not too sure if it is an overkill or its to direction to go.

Upvotes: 0

Views: 591

Answers (1)

Zhong Wu
Zhong Wu

Reputation: 2024

Yes, what you want to achieve is absolutely possible within Forge. Actually, there are 2 ways to get the properties for an object. Either from server side(Model Derivate API) or client side(Forge Viewer API), I listed both of them here in case you are interested. But for your case, I think the 2nd way to use Forge Viewer API is more suitable.

1st solution, with Model Derivative API, it provides the following 3 APIs, the 1st API is used to get a list of model view Ids for a design model. Then, you can use the 2nd API to get a hierarchical list of objects for the model view. With the last API, you can get all the properties for the specified object that is represented by guid.

Please check the Model Derivative API for the details about following 3 APIs.

GET :urn/metadata

GET :urn/metadata/:guid

GET :urn/metadata/:guid/properties

2nd Solution is using Forge Viewer API, first, you need to register an event of SELECTION_CHANGED_EVENT, within that event, it’s easy to get dbId of the selected object, and use the API getProperties as follow to fetch all the properties you want, then perform some sql query with this property as you want. The code snippet is as follow, and I have a small sample code to demonstrate the solution if you are interested.

            currentModel.getProperties(dbId, function(result) {
                console.log("List properties of DbId:" + dbId);
                if (result.properties) {
                    result.properties.forEach(function(prop) {
                        // call API to perform sql query with the property you are interested
                        console.log(prop);
                    });
                };
            });

Hope it helps.

Upvotes: 2

Related Questions