Autodesk Forge, Translator using wrong rootFile - autodesk-forge

Summary
When I upload a zip file containing multiple SolidWorks assemblies and parts, an assembly contains the same name as my rootFile, and my rootFile is sorted later in a alphabetic order. The translator is using the wrong rootFile for the translation.
Could this be a bug in the translation service?
Example
example.zip
├── part1.sldprt
├── part2.sldprt
├── an assy.sldasm <-- This file will be selected by translator
└── assy.sldasm <-- This file is selected as rootFile
Let's say I upload the zip file above, "example.zip", and then request a translation with "assy.sldasm" as rootFile.
After completion, when I request the manifest of the translated file, the "rootFile"is now "an assy.sldasm".
Conclusion
My conclusion is that the translator matches filenames without requiring a match on the full filename.
This means, that because assy.sldasm is sorted after an assy.sldasm it will match to an assy.sldasm first.
Files to replicate the issue can be sent upon request.

posting the comment as an answer for more searchable by others:
Although I have not dataset of Solidworks, I can reproduce this problem with linked files of Inventor, AutoCAD or Revit. it looks translation job finds the file which contains the string rootFileName, and returns the first one (in sorted) ,instead of matching exact the string of rootFileName. Sorry for the problem. I logged it with our engineer team: DERI-5444

Related

"Query String" inside URL segments?

Take the example question https://stackoverflow.com/questions/3563957/https-url-path-and-query-string.
As you can see, we have the segment /questions followed by what I'm assuming is the question ID, /3563957. In my head, this would indicate a folder structure like:
.
└── questions/
└── 3563957
However, I can't imagine a directory is being generated for each question. To me, this seems like a query string that is being used as a URL segment. How is this accomplished?
This is accomplished on the server side. When the server sees the request, it likely doesn't treat the url like a directory. This can be accomplished many different ways depending on what you are using for your server.

Upload a zip file for translation in Autodesk Forge

I have a zip file containing several .CATPART, .CATDRAWING and one main .CATPRODUCT file. is it possible to upload all the files ( as a zip) and get the model translated ? and possibility of setting the main file. And is this tutorial still valid ?
Translating a ZIP file with multiple designs in it is possible. See this tutorial, specifically task #3 step #1.
Note however that the .CATDRAWING may not be processed during the conversion. See the list of supported translations.

Autodesk Forge download object, but cannot tell if it is a Revit model or zip file

I was downloading Revit models from BIM360 team hub via ForgeAPI using the following uri.
https://developer.api.autodesk.com/oss/v2/buckets/:bucketKey/objects/:objectName
All my objectName ended with .rvt. So I downloaded and saved them as rvt file.
However I noticed that some of the files cannot be opened by Revit. They are actually not rvt files but zip files. So I have to change the extension to .zip and unzip the file to get real 'rvt` files.
My Problem is that not all files is zip file. I cannot tell from the API because the URI I request is always ended with .rvt.
Every Unix OS provides the file command, a standard utility program for recognising the type of data contained in a computer file:
https://en.wikipedia.org/wiki/File_(command)
A zip file is directly recognised and reported like this:
$ file test_dataset.zip
test_dataset.zip: Zip archive data, at least v2.0 to extract
A Revit RVT model is a Windows compound document file, so it generates the following output:
$ file little_house_2021.rvt
little_house_2021.rvt: Composite Document File V2 Document, Cannot read section info
Hence you can use the same algorithm as file does to distinguish between RVT and ZIP files.
Afaik, file just looks at the first couple of bytes in the given file.
The Python programming language offers similar utilities; try an Internet search
for distinguish file type python; the first hits explain
How to check type of files without extensions in Python
and point to the filetype Python project.
Other programming languages can provide similar functionality.

How can I find which Revit files are linked in BIM 360 via Forge?

In certain circumstances, BIM360 will serve a zip file of a Revit document along with its links, such as explained here: https://forums.autodesk.com/t5/bim-360-document-management/linked-revit-files-in-bim-360-docs/td-p/8774004
In this circumstances, however, when interacting with GET projects/:project_id/folders/:folder_id/contents the file still is shown as a regular file (potentially the isCompositeDesign attribute distinguishes it) with a .rvt file extension. In addition, the filesize shown in storageSize of the object is the sum of the main Revit file and all of its links. Checking the details in GET buckets/:bucketKey/objects/:objectName/details equally show the size object size attribute to be the sum of the main Revit file and all of its links.
I cannot seem to find functionality in Forge that:
Distinguishes a zip file from a lone file (potentially the isCompositeDesign attribute does this)
Provides a list of which other files are linked into the main file, or a list of the zip file contents and their URNs.
Provides a true filesize of the main revit file itself, not just the sum of all linked files in the zip.
Ideas?
Revit 4 worksharing, publishes a file to BIM360.
This file is named as a .rvt file (ie. 'mybigrevitproject.rvt'), but in fact, it's really a zip file in disguise. If you rename it to zip, download it, and unzip it, you'll find lots of .RVT inside the zip.
There's a neat trick to figuring this out, without downloading the entire file.
Use a range GET on the first 16 bytes, and check for the magic header.
For full details, check out this repo: https://github.com/wallabyway
Here's a snippet of the code that will help:
https://github.com/wallabyway/bim360-zip-extract/blob/master/server.js#L167
I think it's related to this question: Forge Data management returns zip file

Swagger API Specification filenames

I'm trying to use Swagger to create API documentation for an API we're building and I've never used it before.
The documentation on Github says that the Resources Listing needs t be at /api-docs and the various resource files need to be at /api-docs/books etc.
This makes naming files and folders very tricky. I think they expect the files to have no file names, rather than having a folder called /api-docs it has to be an extension-less file, then you can't put the resources in an api-docs folder because you can't call the folder that, so they suggest using a folder called /listings.
This folder doesn't appear in the URL structure of your documentation though, it's kind of invisible because you set the baseURL in your resources to the proper path, but it looks like that has to be an absolute path, which is awkward if you want to have it on several servers (local and production).
Maybe I just don't get it but this all seems to be absolutely nuts.
So, I have 2 questions.....
1) Can I give my resource listing file and my resource files a .json extension? This would make sense as it's a JSON file.
2) Can I use a relative path to the resource listing file in the baseURL in my resource files?
Ideally, my file structure would be flatter, like this...
/api-docs
resources.json
books.json
films.json
Is Swagger flexible enough to do this?
It's an IIS server if that makes any difference (if the solution requires routing for example).
I was able to put model files into a folder under the web root and could reference them like this.
$ref: '/models/model.yml#/MyObject'
Relative paths also worked without a leading slash.
$ref: 'models/model.yml#/MyObject'
Inside the model.yml, I can reference other objects int eh same file like this
$ref: '#/MyObject2'.
However, I could only get the main swagger file to import model files. I could not get one model file to cross-reference another model file.
I was using a Tomcat web server but the principle will be the same.