Autodesk setreference for child assemblies not working

414 views Asked by At

I am having trouble referencing child assemblies that are required for a parent assembly translation.

First I POST to https://developer.api.autodesk.com/references/v1/setreference with the following body

{ 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' } } ] }

After setting references, I request translation and get the following result of the translation:

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

After that I get the manifest for the urn and it is as follows:

{ 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' } ] } ] }

Using the same code path I can successfully render an assembly with non-assembly child parts that have been set using setreference, but when rendering an assembly with child assemblies, setreference doesn't seem to set the references to the child assembly files successfully. Is there something wrong in my sequence for setting references to child assemblies?

2

There are 2 answers

0
Xiaodong Liang On BEST ANSWER

I discussed with @sabrehage and finally got the working codes.

firstly, it is recommended to use Forge Derivative API v2 (zip + specify root file only), by which, the API user does not need to specify the references explicitly.

If you still want to use Forge Derivative API v1, the following is the note:

In local Inventor, the file references are managed by Inventor Project. Inventor will look for the ref files firstly in the specific folders of the Project, then look for the relative paths. Obviously, when the files are uploaded to bucket of Forge, no project file, all files are in the same level in physical perspective. So in v1, it depends on the reference file that the sender specifies.

If the hierarchy is like:

Top Assembly.iam
    part1.ipt
    part2.ipt

The reference file can be simply composed like what is mentioned in the blog: http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html.

In the dataset of @sabrehagen, the hierarchy contains nested assemblies, even in sub folder:

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

The correct way is to specify in one call (for top assembly only), and specify the subfolder in the reference map. In addition, we should define path name with original name, instead of that has been URL encoded. i.e.

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

If without specifying subfolder, Forge thinks all files are within the same level, but it conflicts to the hierarchy of the last saving (absolute path). So it failed to find the corresponding files in the bucket.

After Forge gets the files and correct reference, it will look at the reference file and create the subfolders if they are specified, then put those files to the subfolder from bucket, finally translate.

3
Xiaodong Liang On

as I remember, you would also need to configure the parts in the web service of set reference. This is a blog: http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html. probably it could help you to diagnose the issue. But, I strongly suggest you migrate to v2, by which you do not need to set reference manually. you can just upload all dataset as a zip file and set which file is the top (root) file, Forge will analyze the hierarchy automatically. This is another blog: http://adndevblog.typepad.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html