1

I am working with AutoDesk Forge Viewer (2D) in Javascript with Offline svf file. I have converted the .dwg file to svf file.

How can I get Model Object Metadata properties in Javascript like we get using the api "https://developer.api.autodesk.com/modelderivative/v2/designdata/{urn}/metadata/{guid}/properties" ?

I tried using viewer.model.getProperties(dbId,function,funtion), but this only gives me details of particular to that dbId but i want the list of properties.

Please help me with this.

1 Answer 1

4

firstly, the other blog talks about how Model Derivative extracts properties. In theory, if you get 'aka json (json.gz)' or 'sqlLite (sdb/db)', you would be able to extract yourself by other tools. How properties.db is used in Forge Viewer?.

I believe you have known http://extract.autodesk.io/ as you said you have downloaded SVF. http://extract.autodesk.io/ provides you with the logic to download translated data, including json.gz and sqlLite db.

While if you prefer to dump all properties within browser by Forge Viewer, the only way I can think is as below:

 function getAllDbIds(viewer) {
   var instanceTree = viewer.model.getData().instanceTree;

   var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);

  return allDbIdsStr.map(function(id) { return parseInt(id)});
}

var AllDbIds = getAllDbIds(myViewer);
myViewer.model.getBulkProperties(AllDbIds, null,
   function(elements){
    console.log(elements);//this includes all properties of a node.
 })

Actually, I combined two blogs: https://forge.autodesk.com/cloud_and_mobile/2016/10/get-all-database-ids-in-the-model.html

https://forge.autodesk.com/blog/getbulkproperties-method

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks this helped me. One more thing wanted to ask, Is there any way in Javascript to get the hierarchical object data like we get in api "developer.api.autodesk.com/modelderivative/v2/designdata{urn}/metadata/{guid}". kindly help me on this.
@Gaurav, InstanceTree of the model contains method to enumerate the tree. This a blog for your reference: forge.autodesk.com/blog/enumerating-leaf-nodes-viewer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.