子程序集的 Autodesk setreference 不起作用

Autodesk setreference for child assemblies not working

我在引用父程序集翻译所需的子程序集时遇到问题。

首先我POSThttps://developer.api.autodesk.com/references/v1/setreference跟下面的正文

{ master: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
     dependencies: 
      [ { file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-e3l7hokp0qxqn227b7qcjo47vi.iam',
          metadata: 
           { childPath: 'fuselage.iam',
             parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } },
        { file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-mhrb7um0of74iasv37nzh0k9.iam',
          metadata: 
           { childPath: 'motor_mount.iam',
             parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } } ] }

设置引用后,我请求翻译,得到如下翻译结果:

{ Result: 'Success',
  Scope: '25660970-8194-4de0-baa4-c8f1f132b2a7',
  RegisterType: [ 'thumbnail', '2dviewing', '3dviewing' ] }

之后我得到骨灰盒的清单,如下所示:

{ guid: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
  owner: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
  type: 'design',
  hasThumbnail: 'false',
  startedAt: 'Wed Jan 04 04:43:59 UTC 2017',
  urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
  region: 'US',
  status: 'failed',
  progress: 'complete',
  success: '100%',
  children: 
   [ { guid: 'aa85aad6-c480-4a35-9cbf-4cf5994a25ba',
       messages: 
        [ { type: 'warning',
            message: 'The drawing\'s thumbnails were not properly created.',
            code: 'TranslationWorker-ThumbnailGenerationFailed' } ],
       name: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
       success: '100%',
       hasThumbnail: 'false',
       role: 'viewable',
       version: '2.0',
       urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
       status: 'failed',
       assetCount: 25,
       type: 'folder',
       progress: 'complete',
       children: 
        [ { guid: '015896d9-e6d3-4be6-8f3d-96da5e64eed3',
            type: 'folder',
            name: 'Scenes',
            status: 'success',
            progress: 'complete',
            success: '100%',
            hasThumbnail: 'false',
            children: 
             [ { guid: '451f7aab-1917-40dd-b117-5dd8f90ab6a7',
                 type: 'geometry',
                 role: '3d',
                 name: 'Scene',
                 status: 'success',
                 messages: 
                  [ { type: 'warning',
                      code: 'ATF-1023',
                      message: 
                       [ 'The file: {0} does not exist.',
                         'X:\Google Drive\SCAAD\PRJ_HAARDCraft\HAARDCraft_JFlight\CAD\Fuselage\fuselage.iam' ] },
                    { type: 'warning',
                      code: 'ATF-1023',
                      message: 
                       [ 'The file: {0} does not exist.',
                         'X:\Google Drive\SCAAD\PRJ_HAARDCraft\HAARDCraft_JFlight\CAD\Engine mount\motor_mount.iam' ] },
                    { type: 'error',
                      code: 'ATF-1026',
                      message: 
                       [ 'The file: {0} is empty.',
                         'C:/worker/viewing-inventor-lmv/tmp/job-1/68/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf' ] } ],
                 size: 27864,
                 progress: 'complete',
                 success: '100%',
                 hasThumbnail: 'false',
                 children: 
                  [ { guid: '6dc4b244-8a47-4a75-bcb3-811dc7b4f294',
                      type: 'resource',
                      urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf',
                      role: 'graphics',
                      mime: 'application/autodesk-svf',
                      size: 27864 } ] },
               { guid: '9bb1adbe-d9d9-4482-ac03-1d60bb0aea36',
                 type: 'resource',
                 urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/properties.db',
                 role: 'Autodesk.CloudPlatform.PropertyDatabase',
                 mime: 'application/autodesk-db',
                 status: 'success',
                 size: 24576 } ] },
          { guid: '039c2bcf-beb7-426b-916c-4a5adb814593',
            type: 'resource',
            role: 'Autodesk.CloudPlatform.DesignDescription',
            urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/xref/designDescription.json',
            mime: 'application/json' } ] } ] }

使用相同的代码路径,我可以成功地渲染一个包含使用 setreference 设置的非程序集子部件的程序集,但是当渲染一个包含子程序集的程序集时,setreference 不会似乎成功地设置了对子程序集文件的引用。我设置子程序集引用的顺序有问题吗?

据我所知,您还需要在 set reference 的 Web 服务中配置这些部分。这是一个博客:http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html。可能它可以帮助您诊断问题。 但是,我强烈建议你迁移到 v2,这样你就不需要手动设置引用了。您可以将所有数据集上传为 zip 文件并设置哪个文件是顶级(根)文件,Forge 将自动分析层次结构。这是另一个博客:http://adndevblog.typepad.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html

我与@sabrehage 讨论并最终得到了工作代码。

首先,推荐使用Forge Derivative API v2 (zip + 仅指定根文件),这样,API 用户不需要明确指定引用。

如果你还想使用Forge Derivative API v1,以下是注意事项:

在本地 Inventor 中,文件引用由 Inventor 项目管理。 Inventor 将首先在项目的特定文件夹中查找 ref 文件,然后查找相对路径。很明显,当文件上传到Forge的bucket中时,没有工程文件,所有文件在物理角度上都处于同一层次。所以在v1中,这取决于发送者指定的参考文件。

如果层次结构是这样的:

Top Assembly.iam
    part1.ipt
    part2.ipt

参考文件可以像博客中提到的那样简单地组成: http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html.

在@sabrehagen 的数据集中,层次结构包含嵌套程序集,即使在子文件夹中也是如此:

topassemb.iam
    part in top assemb.ipt
    subassem folder
        subassem.iam
        part1 in sub assem1.ipt
        part2 in sub assem1.ipt

正确的方法是在一次调用中指定(仅针对top assembly),并在参考图中指定子文件夹。另外,我们应该用原来的名字来定义路径名,而不是已经URL编码的。即

{
    "master" : "urn:adsk.objects:os.object:adsk2017-8/topassemb.iam",
    "dependencies" : [
        {
            "file" : "urn:adsk.objects:os.object:adsk2017-8/subassem.iam",
            "metadata" : {
                "childPath" : "subassem/subassem.iam",
                "parentPath" : "topassemb.iam"
                }
        },
        {
            "file" : "urn:adsk.objects:os.object:adsk2017-8/part1%20in%20sub%20assem1.ipt",
            "metadata" : {
                "childPath" : "part1 in sub assem1.ipt",
                "parentPath" : "subassem/subassem.iam"
                }
        },
        {
            "file" : "urn:adsk.objects:os.object:adsk2017-8/part2%20in%20sub%20assem1.ipt",
            "metadata" : {
                "childPath" : "part2 in sub assem1.ipt",
                "parentPath" : "subassem/subassem.iam"
                }
        },
        {
            "file" : "urn:adsk.objects:os.object:adsk2017-8/part%20in%20top%20assemb.ipt",
            "metadata" : {
                "childPath" : "part in top assemb.ipt",
                "parentPath" : "topassemb.iam"
                }
        } 
    ]
}

如果不指定子文件夹,Forge认为所有文件都在同一层级,但与上次保存的层级(绝对路径)冲突。所以在bucket中没有找到对应的文件。

Forge 获取文件和正确的引用后,它会查看引用文件并创建指定的子文件夹,然后将这些文件从存储桶中放入子文件夹,最后进行翻译。