首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >伪造autodesk viewer api,onDocumentLoadFailure() -错误代码:4

伪造autodesk viewer api,onDocumentLoadFailure() -错误代码:4
EN

Stack Overflow用户
提问于 2019-02-03 21:59:58
回答 1查看 371关注 0票数 0

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

代码语言:javascript
运行
复制
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>
EN

回答 1

Stack Overflow用户

发布于 2019-02-04 23:25:05

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

如果您仍然有问题,请随时向我们发送电子邮件到forge (dot) help (at) autodesk (dot) com,并包括有关您的项目的尽可能多的详细信息,例如,访问令牌看起来是什么样子,您的模型的骨灰盒,您的Forge应用程序ID等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54503626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档