【问题标题】:How do I download SVG/SVF for offline viewing with Autodesk Model Forge APIs如何下载 SVG/SVF 以使用 Autodesk Model Forge API 进行离线查看
【发布时间】:2017-06-19 23:30:51
【问题描述】:

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

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"}

【问题讨论】:

    标签: autodesk autodesk-forge autodesk-viewer autodesk-model-derivative


    【解决方案1】:

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

    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现场测试

    【讨论】:

    • 我正在使用你的气泡对象。效果很好。谢谢。
    【解决方案2】:

    urn 应该是 url 编码的,而不是 base64 编码的。

    【讨论】:

      猜你喜欢
      • 2021-02-25
      • 2019-05-02
      • 2020-09-30
      • 2021-06-19
      • 2021-10-11
      • 2019-05-04
      • 1970-01-01
      • 2019-12-29
      • 2020-05-03
      相关资源
      最近更新 更多