Creating a viewer application with an URN from Autodesk A360

对着背影说爱祢 提交于 2019-12-01 00:56:02

You can look at the following three samples on GiHub that all three access CAD models on A360 and display them in the viewer:

Data Management APIP sample: https://github.com/Developer-Autodesk/data.management.api-nodejs-sample

Model Derivative API sample: https://github.com/Developer-Autodesk/model.derivative.api-nodejs-sample

Real-time round-trip BIM editor: https://github.com/jeremytammik/model.derivative.api-nodejs-sample-roomedit3d

Proof that it works is provided by the roomedit3dv2 round-trip Forge BIM edi, 8 minute demo recording:

https://www.youtube.com/watch?v=bDI5YX7PDP8

Good luck!

After comparing my solution against Augusto Goncalves' application at https://github.com/Developer-Autodesk/data.management.api-nodejs-sample, I finally managed to solve the problem.

  • Instead of downloading the project and uploading it to my own bucket, as described in https://developer.autodesk.com/en/docs/data/v2/tutorials/app-managed-bucket/, gotten the identificator (urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1) from the result of the file request and converted it to an URL-friendly Base64 (dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXktYnVja2V0L215LWF3ZXNvbWUtZm9yZ2UtZmlsZS5ydnQ=).

Although this method returns a correct URN, then in addition to URN an acmsession must be also added to the request. From the sample code above, I managed to reverse-engineer the following request:

curl -X 'POST' \
 -H "Authorization: Bearer $token" -H 'Content-Type: application/json' \
 -v 'https://developer.api.autodesk.com/oss-ext/v1/acmsessions' -d \
 '{
    "application": "autodesk",
    "x-ads-acm-check-groups": "true",
    "x-ads-acm-namespace": "WIPDM"
  }'

The result of this request returns a code, which must be added to the URN. Instead of adding it to the end of request URL, it should be added to the method that is being called:

viewer.load(doc.getViewablePath(geometryItems[0]), null, null, null, doc.acmSessionId /*session for DM*/);

Using this solution required changes to be made to the instantiation of the viewer. Instead of doing it like described in https://developer.autodesk.com/en/docs/viewer/v2/tutorials/basic-viewer/, I changed it to the solution that is in index.js file of the sample code above.

I've got confirmation from the development team that you should not use the ACM headers or rely on the WIPDM urn to load directly your viewable. This will stop working at some point in the future. We will add some logic directly in the derivative service to abstract it and allow you to do that.

At the moment unfortunately, prefer to use the storage URN from the A360 item version and post a custom svf job that will produce a new set of viewables you can rely on.

You can see a concrete example in my forge sample

//pick the last version by default
var version = item.versions[ item.versions.length - 1 ]

var storageUrn = window.btoa(
    version.relationships.storage.data.id)

// !IMPORTANT: remove all padding '=' chars
// not accepted by the adsk services

storageUrn = storageUrn.replace(new RegExp('=', 'g'), '')

var urn = version.relationships.derivatives.data.id

console.log('A360 URN: ' + urn)  // -> just for info
console.log('Storage URN: ' + storageUrn) // -> use this URN to POST svf and trigger translation
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!