如何使用Autodesk Model Forge API下载SVG / SVF进行离线查看(How do I download SVG/SVF for offline viewing with Aut

编程入门 行业动态 更新时间:2024-10-25 19:30:07
如何使用Autodesk Model Forge API下载SVG / SVF进行离线查看(How do I download SVG/SVF for offline viewing with Autodesk Model Forge APIs)

我能够完成上传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”}

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 returns: {"diagnostic":"Derivative api only supports adsk.viewing & adsk.objects urn"}

最满意答案

如果您希望获取所有必需的文件以供离线查看,则有几个步骤。 首先检查提取项目中的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上进行测试

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) ; }) ; })) ; } ;

Test it live at https://extract.autodesk.io

更多推荐

本文发布于:2023-08-02 15:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1378337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:离线   如何使用   Forge   API   SVG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!