show linked files in autodesk forge viewer - autodesk-forge

i am trying to make auto-desk forge viewer.
using this link Forge & ASP.NET: from zero to hero in 30 minutes
and it works fine with single revit file.
now i want to view revit document that has linked document and i found this post How to Set References with Revit Files for View and Data API
but i think it is an old version of api.
so i don't know how to apply these steps in the viewer code.
any help

A zipped file which is contained the host RVT file and corresponding linked files can help you archive this goal. After uploading this ZIP file to the Forge DM, you have to make sure that ‘compressedUrn: true’ and ‘rootFilename: {your host RVT filename with the sub filename .rvt}’ your input field of the job configuration body while submitting your translation job. Please refer here for the details: https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/

Some more info:
If you do not want to manage the reference, while simply count on Forge detects the reference automatically, the choice is what Eason mentioned: package all files in an zip, upload, and ask Forge Post Job service to translate the zip. You only need to specify the root file.
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/
This blog tells more:
https://forge.autodesk.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html
If you want to manage the reference, e.g. in one time, you have uploaded all files of one version or only a few files of the package. While after some time, some files need to be updated, or are not referred anymore, but it is unnecessary to upload all related files again (as in #1, upload zip again).
In such scenario, the choice is, firstly, set reference manually by another Forge service (Set Reference):
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-references-POST/
next, ask POST Job service to translate:
https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/

As of 1/2020 Autodesk has said that they do not support reference endpoint when exporting to SVG so zip file is the only supported method currenty.

Related

How can I download the svf file in the forge api?

How can I convert the file I uploaded to Forge to svf format and then download it to my own server?
I wanted to do these operations using your project "https://github.com/Autodesk-Forge/forge-bucketsmanager-desktop/tree/master/bucket.manager". As a result, I downloaded it, but there are files in it that I will not use. The reason for this is that the load on the download process increases. I just want the "3d views" folder. Can you help with this?
As Alex said, the structure of an SVF asset can vary depending on the input file format. For more details on how to download the SVF (or just some of its parts), take a look at the forge-convert-utils library, specifically the SvfDownloader. It parses the actual SVF file to identify all the additional assets (e.g., geometry files, textures, property database files, etc.) that need to be downloaded as well.

directly get svf from BIM360 hub/project/model

instead of using Model Derivative, is it possible to get file in SVF format directly from BIM360 model which has already been converted to SVF or SVF2 format? I mean not using MD service at all, thanks.
To download SVF dataset (no matter from your own bucket, or from BIM360), you need to use Forge Derivative API to get manifest (GET:manifest) info and metadata (GET:Metadata) info. The info will tell the relative cloud path of the *.svf, while *.svf stores the index of the dataset. Then download them one by one.
We have a few code that demo how to download SVF data to local. The most updated one I would recommend is my colleague Petr composed:
https://github.com/petrbroz/forge-convert-utils
It targets to convert SVF to glTF, but it has quite a few granule modules, one of which can download SVF data.
you could perform a simple test:
download the source code of the tool
run npm install
run npm run-script build
export your Forge client id and secret to env
run node samples/download-svf.js <your model urn of BIM360> <local path>
It will start the process to get manifest and download the SVF data one by one to local. This is a screenshot with my test. If you work with js, typescript, you could merge the module to your workflow.
In the context of BIM360, the uploaded models will be translated to SVF(s) automatically. So you can get the metadata, properties or load in Forge Viewer directly. This is a tutorial on how to work with BIM360 hub/project/folders/item/versions, in which no specific step to translate models.
https://learnforge.autodesk.io/#/tutorials/viewhubmodels
Pease note: this encourages the programmers, solution builders to provide extensible abilities for the end users of BIM360, adding more values for them. It does not mean to be an alterative to bypass model derivative when the solution is not for BIM360 users.

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

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.

F2D streaming broken by non-streaming unzip error in Forge Viewer

I am testing viewing documents in the Forge Viewer after downloading the Bubble's locally. I've been successful up to this point with most formats but am having trouble with PDF's.
I was able to use the extractor project https://github.com/cyrillef/extract.autodesk.io with some modifications to get the PDF to extract. Investigating the downloaded files, they look to be correct.
However, when I go to load this file into the viewer I get the following error.
F2D streaming broken by non-streaming unzip!
Any details on what this means and how to fix it?
Unfortunately, there is no formal documentation to set viewer up for viewing PDFs.
Current solution is pointing to initialize your viewer with the Autodesk.Viewing.ViewingApplication. It will obtain additional configuration values from the manifest for viewing PDFs. You can still retrieving the viewer instance via the Autodesk.Viewing.ViewingApplication.prototype.getCurrentViewer().
Here is the tutorial for the Autodesk.Viewing.ViewingApplication:
https://developer.autodesk.com/en/docs/viewer/v2/tutorials/basic-application/