简体   繁体   English

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

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

i want to use the autodesk's viewer in my application so i used the forge ph client sdk,i made the 5 steps that are herehttps://forge.autodesk.com/blog/basic-usage-forge-sdk-php everything worked good. 我想在我的应用程序中使用Autodesk的查看器,所以我使用了伪造的ph客户端sdk,我在这里做了5个步骤https://forge.autodesk.com/blog/basic-usage-forge-sdk-php一切正常。 but now, i want to view files in the viewer but it doesn't work i have thies error in my browser's concole :onDocumentLoadFailure() - errorCode:4 但是现在,我想在查看器中查看文件,但是它不起作用,我在浏览器的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>

Error code 4 refers to situations where the viewer gets 403 Access Denied when trying to download files from Forge. 错误代码4表示在尝试从Forge下载文件时查看器获得403 Access Denied情况。 Make sure that the access token you're providing to the viewer is valid and that it has access to the model you're trying to view. 确保您提供给查看器的访问令牌有效,并且可以访问您要查看的模型。

If you're still having issues, feel free to shoot us an email to forge (dot) help (at) autodesk (dot) com, and include as many details about your project, for example, how does the access token look like, the URN of your model, your Forge app ID, etc. 如果您仍然遇到问题,请随时向我们发送电子邮件,以伪造(dot)帮助(在autodesk(dot)com上),并提供有关项目的尽可能多的详细信息,例如,访问令牌的外观如何,模型的URN,Forge应用程序ID等。

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

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