22 Jul 2016

Show an A360 file in the Viewer

Default blog image

This will likely be improved, but currently in order to show an A360 item in the Viewer you'll also have to use the Model Derivative API on the item - as mentioned by Philippe too here: 
http://stackoverflow.com/questions/37835178/creating-a-viewer-application-with-an-urn-from-autodesk-a360

So first you need to get to the version of the item you want to show in the viewer. You can just follow the steps here to get to the item version you want: 
https://developer.autodesk.com/en/docs/data/v2/tutorials/download-file/

Following the sample's values that you got back in Step 3, you'll see that the returned value contains the items and their versions as well. And the version also contains a storage section under relationships with the id we need:

{
      "type": "versions",
      "id": "urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1",
      "attributes": {
        "name": "House Design.rvt",
        "displayName": "House Design.rvt",
        "createTime": "2016-05-24T19:25:23+00:00",
        "createUserId": "38SCJGX4R4PV",
        "lastModifiedTime": "2016-05-24T19:25:23+00:00",
        "lastModifiedUserId": "38SCJGX4R4PV",
        "versionNumber": 1,
        "mimeType": "application/vnd.autodesk.revit",
        "fileType": "rvt",
        "storageSize": 12550144,
        "extension": {
          "type": "versions:autodesk.core:File",
          "version": "1.0",
          "schema": {
            "href": "https://developer.api.autodesk.com/schema/v1/versions/versions%3Aautodesk.core%3AFile-1.0"
          },
          "data": {}
        }
      },
      "links": {
        "self": {
          "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1"
        }
      },
      "relationships": {
        "item": {
          "data": {
            "type": "items",
            "id": "urn:adsk.wipprod:dm.lineage:6bVr4EVDSaOpykczeQYR2Q"
          },
          "links": {
            "related": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/item"
            }
          }
        },
        "refs": {
          "links": {
            "self": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/relationships/refs"
            },
            "related": {
              "href": "https://developer.api.autodesk.com/data/v1/projects/a.cGVyc29uYWw6cGUyOWNjZjMyI0QyMDE2MDUyNDEyOTI5NzY/versions/urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q%3Fversion%3D1/refs"
            }
          }
        },
        ... 
        "storage": {
          "data": {
            "type": "objects",
            "id": "urn:adsk.objects:os.object:wip.dm.prod/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
          },

Now you just have to base64 encode that urn and use it with the Model Derivative API to post an svf translation job for that file:
https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/

That's it.

Tags:

Related Article

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...