0

I am trying to collect all the objects properties by its dbIds in a for each. But for the first dbId in the array I am getting the properties and other objects properties I am getting an empty array. As below,enter image description here

Already someone has posted the same question, Problems with getting the properties of an ID when looping over all Ids

Is that possible to get all objects properties in client side itself without hitting the Forge API for accessing its properties?

  • the RESt call "GET :urn/metadata/:guid/properties" will get you all properties and doesn't cost any cloud credits, so it's not clear to me why you would like a different approach. The other way would be as Xiaodong mentioned to use getBulkProperties and provide the list of all dbIds in the model, which you can get as follow: https://forge.autodesk.com/cloud_and_mobile/2016/10/get-all-database-ids-in-the-model.html. This requires you to load the model in the viewer. If you want to do it without loading the model, you could extract the viewables but much harder comparing to those 2 suggestions – Felipe Sep 04 '17 at 12:01
  • Hi, Philippe, the problem in using derivate API was I am not able to get properties of my 2d AutoCAD files. Check this link https://stackoverflow.com/questions/45790913/how-to-extract-geometric-positions-from-2d-dwg-using-forge-autodesk-apis – jothi pandiyan Sep 05 '17 at 05:38

1 Answers1

0

Two ways to get all properties of the model: one is at backend as mentioned in the other post, i.e. call the endpoints of model derivatives. The other is what you are trying, dumping the properties by getProperties.

if you wanted to get specific properties, getBulkProperties is the choice: https://forge.autodesk.com/blog/getbulkproperties-method

the code in the other post looks fine to me, but I do not either make it work. I doubt if Forge Viewer js codes is well compatible with ES6 for this method. I will dig into further. However it looks the JavaScript codes before ES6 can work.

`

for(var id in allDbIds)
  {
    console.log(id); 
    NOP_VIEWER.getProperties(id,
      function(result)
        {
          console.log(result);
        },
      function(err)
        {
          console.log(err);
        });
  }

`

enter image description here

Xiaodong Liang
  • 2,051
  • 2
  • 9
  • 14