本文介绍了如何下载 SVG/SVF 以使用 Autodesk Model Forge API 进行离线查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够完成上传 Revit 文件以及在查看器中翻译和加载的所有步骤.我现在正在尝试下载翻译的 SVG/SVF 以供离线查看.我找到了对以下端点的引用,并用这个进行了测试:

I am able to accomplish all steps to upload Revit files and translate and load in viewer. I am now trying to download the translated SVG/SVF for offline viewing. I found reference to the following endpoint and tested it out with this:

function download(){
var uri = 'https://developer.api.autodesk.com/derivativeservice/v2/derivatives/<<urn>>' ;
var authorizationHeader = 'Bearer <<token>>'

request.get(
    {
        url: uri,
        headers:
        {
            'Authorization': authorizationHeader,
            'Accept-Encoding': 'gzip, deflate'
        },
    },

    function(error, response, body){
        if(!error){
            console.log(body);
        }else{
            console.log(error);
        }
    });
}

API 返回:
{"diagnostic":"Derivative api 只支持 adsk.viewing & adsk.objects urn"}

推荐答案

如果您想获取所有必需的文件以供离线查看,有几个步骤.首先检查 downloadBubble 方法(node.js) 在摘录 project 中:

There are several steps if you desire to grab all the required files for offline viewing. Start by checking the downloadBubble method (node.js) in extract project:

this.downloadBubble =function (urn, outPath) {
    var self =this ;
    self._outPath =outPath ;
    return (new Promise (function (fulfill, reject) {
        self._progress.msg ='Downloading manifest' ;
        self.getManifest (urn)
            .then (function (bubble) {
                //utils.writeFile (outPath + 'bubble.json', bubble) ;
                self._progress.msg ='Listing all derivative files' ;
                self.listAllDerivativeFiles (bubble.body, function (error, result) {
                    self._progress._filesToFetch =result.list.length ;
                    console.log ('Number of files to fetch:', self._progress._filesToFetch) ;
                    self._progress._estimatedSize =0 | (result.totalSize / (1024 * 1024)) ;
                    console.log ('Estimated download size:', self._progress._estimatedSize, 'MB') ;

                    //self.fixFlatBubbles (result) ;
                    //self.fixFusionBubbles (result) ;

                    self._progress.msg ='Downloading derivative files' ;
                    self.downloadAllDerivativeFiles (result.list, self._outPath, function (failed, succeeded) {
                        //if ( ++self._done == 1 /*2*/ )
                        //  return ;
                        self.failed =failed ;
                        self.succeeded =succeeded ;
                        fulfill (self) ;
                    }) ;
                }) ;
            })
            .catch (function (err) {
                console.error ('Error:', err.message) ;
                self._errors.push (err.message) ;
                reject (self) ;
            })
        ;
    })) ;
} ;

https://extract.autodesk.io

这篇关于如何下载 SVG/SVF 以使用 Autodesk Model Forge API 进行离线查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 13:59