繁体   English   中英

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

[英]forge autodesk viewer api , onDocumentLoadFailure() - errorCode:4

我想在我的应用程序中使用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>

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM