Is it possible to get urns of models which are translated as references via zip translation? - autodesk-forge

When I upload and translate a zip-file with one rootFile and some models which act as references to Autodesk-Forge, I could only find one model-urn afterwards. Are all models uploaded separately under the hood and do you have the possibilty to get the urns of each model?
One usecase would be to open any other model from the package than the predefined root, to get to view the 2D-sheets from this model.
Another usecase would be to save data in relation to elements/referenced models with their dbId/guid and urn.
I was expecting to get each models urns by selecting parts from different models and running this.viewer.getAggregateSelection().lastItem.model as it would do the trick if I would've translated them separately and aggregated the view. But this way there's just one urn for all elements.
I also tried inspecting the buckets and objects via the awesome "Autdesk Forge Tools" extension for VSCode, but couldn't get any deeper than the .zip file as an object in the bucket.
Is the only possibility to upload/translate the same .zip-package for every model i want to open with a new defined rootFilename again? Is this still the only possibility as stated in an answer from 2016? (https://stackoverflow.com/a/38720162/19956654)
Appreciate any help with this one, thanks in advance!

Unfortunately, one ZIP will have one URN only. So, you will need to have the ZIP uploaded with different names and request translations with different rootFilenames separately.
However, you don't really need to upload the same file several times. Just call PUT buckets/:bucketKey/objects/:objectKey/copyto/:newObjectKey to duplicate the uploaded ZIP with different names.

Related

Forge - Upload multiple 3d files to a project so that I can see all of them combined on the viewer

I need to upload multiple 3d files, and see them combined in one viewer. I am using this library
"forge-apis": "^0.9.2"
I know this is possible but I haven't found anything in the documentation about that. I know that using model derivative I can combine files but that is in the case I am uploading in chunks.
An example to upload would be:
MAIN-FOLDER/
some-file.rvt
CAD/
file1.pdf
file2.pdf
PDF/
file1.pdf
file2.pdf
TEXTURES/
file1.jpg
file2.jpg
So, how could I approach this.
Thanks!
You can (and in this case, should) upload and translate the files individually. Later, you can load (or "aggregate") them all into a single viewer instance. You can find more details about the aggregation in viewer on our blog, for example:
https://forge.autodesk.com/blog/aggregate-multi-models-sequence-forge-viewer
https://forge.autodesk.com/blog/multi-model-refresher
Btw. there's also an option to upload and translate multiple files in a single ZIP archive, however this is typically only used in situations where multiple design files are referencing each other.

Autodesk-Forge bucket system: New versioning

I am wondering of what is the best practise for handling new version of the same model in the Data Management API Bucket system
Currently, I have one bucket per user and the files with same name overwrites the existing model when doing a svf/svf2 conversion.
In order to handle model versioning in be the best manner, should I :
create one bucket per file converted
or
continue with one bucket per user.
If 1): is there a limitation of number of buckets which is possible to create?
else 2): How do I get the translation to accept an bucketKey different than the file name? (As it is now, the uploaded file need to be the filename to get the translation going.)
In advance, cheers for the assistance.
In order to translate a file, you do not have to keep the original file name, but you do need to keep the file extension (e.g. *.rvt), so that the Model Derivative service knows which translator to use. So you could just create files with different names: perhaps add a suffix like "_v1" etc or generate random names and keep track of which file is what version of what model in a database. Up to you.
There is no limit on number of buckets, but it might be an overkill to have a separate one for each file.

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 - Post Jobs - Must files be in buckets and proper URN

I am working on doing a post job and I am confused about where files need to be to run the job and the proper urn.
The examples all use a file that the user uploads to a bucket. I am trying to run the post job on a file that a user has created in Fusion 360 and that he has selected through a GUI I created. The urn in question is obtained by letting the user select the hub, project, folder(s), and file. I then use this file urn on the post job.
I keep getting back the response of :
Failed to download the design description for the input design.
My questions are:
Is it possible to do this from a users hub or do all items have to be in buckets?
Where are those translated files stored once created? If I want to get data like volume and mass without storing the translated file, is that possible?
I took the "urn:" off the front of the urn and got a different error, which I believe meant that it couldn't find any file.
Invalid 'design' parameter.
So, it looks like the urn I am using is finding a file but there is an issue somewhere that is preventing that file from being accessed or translated or something.
I keep getting back the response of : Failed to download the design description for the input design.
For Fusion 360 files make sure the extension name of the object is f2d/f3d. BTW Forge Viewer support these two formats directly so you don't have to translate to SVF for Viewer to visualize them.
Is it possible to do this from a users hub or do all items have to be in buckets?
For hub project items use the Data Management API to obtain the object ID - be sure to include the version parameter in your URN - see GET projects/:project_id/folders/:folder_id/contents and use the id of the item as your URN as well as tutorial here to help you understand how project folder items work.
Where are those translated files stored once created? If I want to get data like volume and mass without storing the translated file, is that possible?
The translated derivatives would be stored separately and you can access them through the derivative manifest. Use GET :urn/metadata/:guid/properties to query derivative properties but you will need to translate the model (to any format will do) in order to extract properties - see tutorial here.

Triggering multiple translations from a single .zip

Is it possible to create multiple viewables from a single .zip upload? Our use case would be to create a viewable for the top level assembly, but then also create viewables of sub assemblies within the same zip.
No direct way to achieve that, you can only trigger a translation against a single file upload. So you could upload the top level assembly as a zip and translate it, then upload separately each sub-assembly (could also be zips if you don't have a flat hierarchy) and translate them one by one or based on your needs.
You would also need to maintain relationships between the top level assembly and the sub-assemblies and their translated URNs on your own.
Hope that helps