Autodesk转换为svf失败

时间:2020-06-18 13:06:54

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

我正在按照本教程中的步骤将文件转换为svf格式,以便能够使用Autodesk Viewer对其进行查看。 https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/prep-file4viewer/

我试图将dwg文件转换为svf。我顺利完成任务3的步骤1,但是在步骤2中,当我发出请求时,得到以下响应:

{"urn":"dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YnVja2V0MTJzL3Zpc3VhbGl6YXRpb25fLV9hZXJpYWwuZHdn",
"derivatives":[{"hasThumbnail":"false","name":"visualization_-_aerial.dwg","progress":"complete",
"messages":[{"type":"error","code":"AutoCAD-InvalidFile",
"message":"Sorry, the drawing file is invalid and cannot be viewed. 
\n- Please try to recover the file in AutoCAD, and upload it again to view."},
{"type":"error","message":"Unrecoverable exit code from extractor: -1073741831",
"code":"TranslationWorker-InternalFailure"}],
"outputType":"svf","status":"failed"}],
"hasThumbnail":"false","progress":"complete","type":"manifest","region":"US","version":"1.0",
"status":"failed"}

我尝试使用他们的在线查看器查看文件,并且能够完美地查看它,因此我知道文件没有任何问题。该错误的可能原因是什么?

编辑:

获取访问令牌并创建存储桶后,我使用此请求将文件上传到存储桶(任务2的步骤2):

curl -X PUT -v 'https://developer.api.autodesk.com/oss/v2/buckets/{bucketname}/objects/visualization_-_aerial.dwg' -H 'Authorization: Bearer {TOKEN}' -H 'Accept-Encoding: gzip, deflate' --data-binary '{PATH_TO_FILE}/visualization_-_aerial.dwg'

对此的响应为200OK。

然后,我使用了教程中提供的在线工具将urn转换为64位编码的urn。

这是我发送的职位发布请求(任务3的第1步):

curl -X POST  'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' -H 'Authorization: Bearer {TOKEN}' -H 'x-ads-force: true' -H 'Content-Type: application/json' -d '{ "input": { "urn": "{URN}", "compressedUrn": true, "rootFilename": "visualization_-_aerial.dwg" }, "output": { "destination": { "region": "us" }, "formats": [{ "type": "svf", "views": ["2d", "3d"], "advanced": {"generateMasterViews": true} } ] } }'

对此的回应是“成功”

和获取请求以检查翻译状态:

curl -X GET 'https://developer.api.autodesk.com/modelderivative/v2/designdata/{URN}/manifest' -H 'Authorization: Bearer {TOKEN}'

对此的回应就是我上面提到的。

文件实际上已上传到存储桶,我可以在https://oss-manager.autodesk.io/#上查看它,但即使在那儿,它也显示翻译失败。

修改2: 这是https://oss-manager.autodesk.io/ get manifest请求(使用开发工具来获取此请求)响应的图像

enter image description here

2 个答案:

答案 0 :(得分:2)

基于上一个答案中添加的注释,看来问题出在上传部分。如您在本教程中所见,它正在使用

--data-binary '@PATH_TO_DOWNLOADED_ZIP_FILE'

@ 符号很重要,如果没有它,您将收到这样的答复

{
"bucketKey" : "adam",
"objectId" : "urn:adsk.objects:os.object:adam/test.dwg",
"objectKey" : "test.dwg",
"sha1" : "cb54c0750e9201bbfa6da6adad6b496bec11a111",
"size" : 27,
"contentType" : "application/x-www-form-urlencoded",
"location" : "https://developer.api.autodesk.com/oss/v2/buckets/adam/objects/test.dwg"
* Connection #0 to host developer.api.autodesk.com left intact
}

看看尺寸:27-绝对不对。因此,当我尝试翻译文件时,会收到与您得到的相同的错误消息。

但是,如果我添加 @ 符号,那么一切都很好:

curl -X PUT -v 'https://developer.api.autodesk.com/oss/v2/buckets/{bucketname}/objects/test.dwg' -H 'Authorization: Bearer {TOKEN}' -H 'Accept-Encoding: gzip, deflate' --data-binary '@/Users/nagyad/Downloads/test.dwg'

注意:我在 Mac 上,在 Windows 上,路径看起来有些不同

回复我这次:

{
"bucketKey" : "adam",
"objectId" : "urn:adsk.objects:os.object:adam/test.dwg",
"objectKey" : "test.dwg",
"sha1" : "d17e9156c948caed3a98788836e6c1f3d5fddadc",
"size" : 55727,
"contentType" : "application/x-www-form-urlencoded",
"location" : "https://developer.api.autodesk.com/oss/v2/buckets/adam/objects/test.dwg"
* Connection #0 to host developer.api.autodesk.com left intact
}

这次,当我尝试翻译文件时,它成功了。

答案 1 :(得分:0)

如果您使用单个文件或使用zip文件,请将 AGCTT 更改为false,因此将其设置为true也请提及 compressedUrn >响应正文中的文件名(根文件名)。