簡體   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