How can I get links between models on BIM 360? - autodesk-forge

I am trying to build a script that transfers files from the Project Files subfolders to the Plans subfolders.
In my BIM 360 Docs I have .rvt models that are linked (e.g. HVAC model linked to the architecture 3D model). When I download a linked model (manually or via the Forge API), I get a .zip file with all the linked models in it.
Is it possible to check which models are linked to an item via the Forge APIs and also in which folder those linked models are stored?
Thank you for your help.
Edit: I tried getting those links by calling versions/:version_id/relationships/refs, but it only shows copies I made from the file.
The links I am trying the get are created in Revit via Insert > Link Revit > Add... and then selecting a file from BIM 360.
Also, when uploading this kind of file (with linked models) manually, to do it correctly I need to select the "upload linked files" option in BIM 360 and then select the parent file.

After you get one version id of one file, you could call versions/:version_id/ relationships/refs. It will tell the relationships of this file with other files. In the structure, fromId is the root file, toId is the xref file. So, if fromId is same to the version_id, that means this file you are checking is a root file. Otherwise, it is one xref (linked) file.
And in the relationships, it will also tell the information of all xrefs file.
The below is the example with my test files.
Root file is urn:adsk.wipprod:fs.file:vf.z4KMn52OT5OIuKamXnzmFw?version=1
Linked file is
urn:adsk.wipprod:fs.file:vf.bIJqAo5-TrCmyMy07ELifw?version=1
Using version id of root file:
https://developer.api.autodesk.com/data/v1/projects/ /versions/ urn%3aadsk.wipprod%3afs.file%3avf.z4KMn52OT5OIuKamXnzmFw%3fversion%3d1/relationships/refs
it returns the structure:
"data": [
{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.bIJqAo5-TrCmyMy07ELifw?version=1",
"meta": {
"refType": "xrefs",
"fromId": "urn:adsk.wipprod:fs.file:vf.z4KMn52OT5OIuKamXnzmFw?version=1",
"fromType": "versions",
"toId": "urn:adsk.wipprod:fs.file:vf.bIJqAo5-TrCmyMy07ELifw?version=1",
"toType": "versions",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/xrefs:autodesk.core:Xref-1.0"
},
"data": {}
}
}
}
],

I also had a lot of trouble to follow links between Revit files on BIM360/ACC and after a lot of research, the situation seems as follows:
There is no way to get links/references for models that are composite designs (ie. downloadable as zip files)
For non-composite models, your mentioned relationships/refs endpoint will return incoming and outgoing references correctly
To check wether an item (revit file) is a composite design or not, check projects/:project_id/items/:item_id/versions. This will return an array of versions, each with attributes.extension.data.isCompositeDesign (bool). If you find versions with isCompositeDesign=false, you can use the relationships/refs endpoint to get all references (of that version).
A model will become composite once there are referenced items with unpublished changes. See here for more details on composite design and here for troubleshooting the creation of cloud compatible links/references.
Models that are composite designs will contain all referenced files including the source file in one zip file. It is noteworthy that the zip file will not contain referenced references, ie. it does not follow references. In other words: If a composite design model references models that are composite designs themselves, the zip file will not contain the zip file of the composite design reference, but only the reference (rvt file) without its references. This makes it very hard, if not impossible, to use design automation in real world scenarios where models often contain sub-references (reference of a reference) and not all the models along the reference chain are untouched, published models.

Related

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

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.

How to put .rfa file on forge design automation?

I want to put file .rfa into Forge DesignAutomation to use function LoadFamily create Special equipment by Revit. I don't know how to put it.
Is it possible to upload the .rfa?
And do i need to configure the activity, bucket or anything else ?
You can send any data to Design Automation job, so that includes rfa files. You may follow any of our code samples (say count.delete) and modify it's activity definition to add an extra parameter and give it an hardcoded local name.
"inputRFA": {
"verb": "get",
"description": "Input Family",
"localName": "input.rfa"
}
When you post your workitem, you can add the inputRFA argument to it with a downloadable link corresponding to the file. This will save your file on the worker machine in the working folder with the hardcoded name provided in the activity parameter input.rfa.
You may then load the family in your appbundle code using:
Family family = null;
document.LoadFamily("input.rfa", out family);
If your input.rfa is always the same for different jobs, you can instead save the family file(s) in the app bundle itself. See some ideas discussed in the blog.

Does this JSON configuration workflow have a name?

I have a system where we collect a lot of JSON configuration from different parties to configure our overall service.
The repository looks like a directory of formatted JSON files. For example foo.json:
{
"id": "3bd0e397-d8cc-46ff-9e0d-26fa078a37f3",
"name": "Example",
"logo": "https://example/foo.png"
}
We have a pipeline whereby the owner of foo.json can overwrite this file by committing a new file at any time, since fast updates are required.
However we require unfortunately to skip whole files or override some values for various $reasons.
Hence we commit something like touch foo.json.skip when we want the file to be skipped before publishing. And similarly, we have a foo.json.d/override.json to perhaps override the logo because it's poorly formatted or something.
Is there a name for this sort of JSON pipeline that we have? It's inspired by systemd configuration, but maybe system configuration was inspired by something else?

Visual Studio Code JSON completion

I'm making my first videogame in Unity and I was messing around with storing data in JSON files. More specifically, language localization files. Each file stores key-value pairs of strings. Keys are grouped in categories (like "menu.pause.quit").
Now, since each language file is essentially going to have the same keys (but different values), it would be nice if VS code recognized and helped me write these keys with tooltips.
For example, if you open settings.json in VS code, if you try to write something, there's some kind of autocompletion going on:
How does that work?
The auto completion for json files is done with json schemas. It is described in the documentation:
https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings
Basically you need to create a json schema which describes your json file and you can map it to json files via your user or workspace settings:
// settings.json
{
// ... other settings
"json.schemas": [
{
"fileMatch": [
"/language-file.json"
],
"url": "./language-file-schema.json"
}
]
}
This will provide auto completion for language-file.json (or any other file matched by the pattern) based on language-file-schema.json(in your workspace folder, but you can also use absolute paths)
The elements of fileMatch may be patterns which will match against multiple files.

show linked files in autodesk forge viewer

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.