Dinesh
Dinesh

Reputation: 21

Is it possible Load pdf sheets from Autodesk Build Sheets into Forge Viewer ? If yes how?

{
            "id": "9c1f5f15-1505-31cd-b755-df87a06b5ad9",
            "number": "A 04",
            "versionSet": {
                "id": "80101fe2-2af5-4cab-8f23-118eb76a516c",
                "name": "sample Test Sheet",
                "issuanceDate": "2023-06-16"
            },
            "createdAt": "2023-06-16T18:14:05.581Z",
            "createdBy": "------",
            "createdByName": "-------",
            "updatedAt": "2023-06-16T18:14:05.631Z",
            "updatedBy": "LPBAKF8D9X4C",
            "updatedByName": "--------",
            "title": "Level4",
            "uploadFileName": "sampleDevTestSheet.pdf",
            "uploadId": "111b4b66-0873-4ec3-8e99-563be66ac8ba",
            "tags": [
                "fima"
            ],
            "isCurrent": true,
            "viewable": {
                "urn": "urn:adsk.bimdocs:seed:a6deb3c3-430d-494b-8de3-414096c0704f",
                "guid": "3214e617-d8f9-37db-aa96-45a73ca4e96b"
            }
        }

After using the GETSheets call from the Sheets API in APS, I obtained the aforementioned result for one of the PDF sheets. Now, my goal is to load this sheet into the Forge Viewer. I have implemented the onDocumentLoadSuccess function and passed the URN from the JSON response after base64 encoding it and adding 'urn:' as a prefix. However, despite these efforts, it is still not working. Can anyone suggest what I might be doing wrong?

        var documentId ='urn:'+urn;
        Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);

        function onDocumentLoadSuccess(doc) {
            var defaultModel = doc.getRoot().getDefaultGeometry();
            viewer.loadDocumentNode(doc, defaultModel);
        }

this is the piece of code i tried ,but this doesnt load pdf into viewer. Suggestions ? Note : the urn i am passing above is after encoding **"urn:adsk.bimdocs:seed:a6deb3c3-430d-494b-8de3-414096c0704f" **

Reference for sheets API : Sheets Reference , Step by step guide P.S. -> I can't use sheets from model or sheets uploaded into ACC-Docs or Files , can only use PDF sheets uploaded into Sheets inside Autodesk Build

Upvotes: 1

Views: 49

Answers (1)

Dinesh
Dinesh

Reputation: 21

Solved!

      function onDocumentLoadSuccess(doc) {
            var viewables = (viewableId ? doc.getRoot().findByGuid(viewableId) : doc.getRoot().getDefaultGeometry());
            viewer.loadDocumentNode(doc, viewables);
}

making above changes to onDocumentLoadSuccess function and using 3legged token was able to load sheet.

Upvotes: 1

Related Questions