伪造的Autodesk Viewer api,onDocumentLoadFailure()-错误代码:4

时间:2019-02-03 13:59:58

标签: javascript autodesk-forge autodesk-viewer

我想在我的应用程序中使用Autodesk的查看器,所以我使用了伪造的ph客户端sdk,我在这里做了5个步骤https://forge.autodesk.com/blog/basic-usage-forge-sdk-php一切都很好。 但是现在,我想在查看器中查看文件,但是它不起作用,我在浏览器的conole中出现了Thies错误:onDocumentLoadFailure()-errorCode:4

function viewObject(access,urn,divId){
var viewer;
var viewerDivId;
var options = {
            env: 'AutodeskProduction',
            accessToken: access

        };
 function onDocumentLoadSuccess(doc) {

        // A document contains references to 3D and 2D viewables.
        var viewables = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {'type':'geometry'}, true);
        if (viewables.length === 0) {
            console.error('Document contains no viewables.');
            return;
        }

        // Choose any of the avialble viewables
        var initialViewable = viewables[0];
        var svfUrl = doc.getViewablePath(initialViewable);
        var modelOptions = {
            sharedPropertyDbPath: doc.getPropertyDbPath()
        };

        var viewerDiv = document.getElementById('viewerDivId');
        viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv);
        viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);
    }

    function onDocumentLoadFailure(viewerErrorCode) {
        console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);

}

function onLoadModelSuccess(model) {
    console.log('onLoadModelSuccess()!');
    console.log('Validate model loaded: ' + (viewer.model === model));
    console.log(model);
}

 function onLoadModelError(viewerErrorCode) {
    console.error('onLoadModelError() - errorCode:' + viewerErrorCode);
}

var documentId = 'urn:'+urn;
viewerDivId = divId;




Autodesk.Viewing.Initializer(options, function onInitialized(){
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});


}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1  /jquery.min.js"></script>

 <script>

    function buttonViewClicked() {
        var access = $('#token').val();
        var urn = $('#urn').val();
        viewObject(access, urn, "MonViewer");
    }
</script>

1 个答案:

答案 0 :(得分:0)

错误代码4表示观看者尝试从Forge下载文件时得到403 Access Denied的情况。确保您提供给查看器的访问令牌有效,并且可以访问您要查看的模型。

如果您仍然遇到问题,请随时向我们发送电子邮件以伪造(dot)帮助(在autodesk(dot)com上),并提供有关您项目的尽可能多的详细信息,例如访问令牌的方式外观,模型的URN,Forge应用程序ID等。