【问题标题】:forge autodesk viewer api , onDocumentLoadFailure() - errorCode:4伪造 Autodesk 查看器 api,onDocumentLoadFailure() - errorCode:4
【发布时间】:2019-06-27 10:55:00
【问题描述】:

我想在我的应用程序中使用 Autodesk 的查看器,所以我使用了 forge ph 客户端 sdk,我完成了这里的 5 个步骤 https://forge.autodesk.com/blog/basic-usage-forge-sdk-php一切正常。 但是现在,我想在查看器中查看文件,但它不起作用我的浏览器控制台中有错误: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>

【问题讨论】:

    标签: javascript autodesk-forge autodesk-viewer


    【解决方案1】:

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

    如果您仍有问题,请随时向我们发送电子邮件以伪造 (dot) help (at) autodesk (dot) com,并包含有关您的项目的尽可能多的详细信息,例如,访问令牌如何看起来像,您的模型的 URN、您的 Forge 应用 ID 等。

    【讨论】:

      猜你喜欢
      • 2021-06-10
      • 2018-06-28
      • 2018-10-22
      • 2019-05-15
      • 2018-05-21
      • 2020-11-09
      • 2018-08-22
      • 2019-11-28
      • 2019-08-30
      相关资源
      最近更新 更多