Capture Autodesk Forge Url by C# - autodesk-forge

I have my own Forge APP now, but after I upload those rvt files I hope to get all of the URLs of those files. Can it be possible?Hope to get Url data automatically. Appreciate for all comments. enter image description here

What kind of URL link do you want? The UI in your snapshot looks like the Fusion Team/BIM360 Team. So, I supposed that you want to view the model with Forge Viewer or download the Revit source file.
To access data of the Fusion Team/BIM360 Team, you can refer to View Hub Model tutorial.
To get data of your Revit files uploaded to the Fusion team, you will need to use those endpoints of Forge Data Management API
GET hubs -> HubsApi#GetHubs
GET projects -> ProjectsApi#GetHubProjects
GET topFolders -> ProjectsApi#GetProjectTopFolders
GET folder contents -> FoldersApi#GetFolderContents
Afterward,
To view the Revit model with Forge View, you need to find the derivative urn under either version tip of the file by this path relationships.derivatives.data.id. e.g.
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLnlDV0dSdUhnUW5PeENIdk1oalQxZEE_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLnlDV0dSdUhnUW5PeENIdk1oalQxZEE_dmVyc2lvbj0x/manifest?scopes=global"
}
}
},
To download the Revit source file, you need to find the storage id under either version tip of the file by this path relationships.storage.data.id. e.g.
"storage": {
"data": {
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/0213357d-03b1-4ab1-95f6-bff154b775ae.ifc"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/0213357d-03b1-4ab1-95f6-bff154b775ae.ifc?scopes=global"
}
}
}
Lastly, please be noted models stored on the Fusion Team/BIM360 Team is on demand translation. Before viewing the model with Forge Viewer, you must open the overview page of the model on your Fusion Team/BIM360 Team project's Web UI like the below, and ensure that here no veiw is loading, then you’re fine to open the model with Forge Viewer, Otherwise, it means your model translation job is still processing.

Related

Translate and View Inventor Files in Forge Viewer

I am trying to load Inventor projects into my Bucket and display them in the Forge Viewer.
For this I downloaded the Inventor example project (Jet Engine Model).
I want to view it in the Forge Viewer just like here (https://forge-digital-twin.autodesk.io/).
I can upload single parts (.ipt) of the project onto my bucket without any problems. But I want to upload and view the whole project (like i do with Revit projects).
When I save the Inventor project as "Pack and Go" and upload the .zip file I get an error message:
{
status code: 400,
statusMessage: 'Bad Request',
statusBody:
{ diagnostic: 'Failed to trigger translation for this file. }
}
Uploading .zip files of Revit (.rvt) or 3D Max (.f3d) Projects works fine.
Unfortunately I have not found anything suitable for this, so I am writing here now.
Is there an example project where I can see how to view whole Inventor projects in the Forge Viewer without linking every .ipt part manually?
I'm not sure how the Inventor "Pack and Go" feature builds the zip file, but please note that when sending zip files to Model Derivative service for translation, the main design file must not be in any subfolder. The contents of the archive could look like this:
- inventor-project.zip
- root-design-file.iam
- some-part-1.ipt
- subfolder
- some-part-2.ipt
- some-part-3.ipt
In this case, the payload to the POST job endpoint should look like this:
{
"input": {
"urn": "<urn of your zip file>",
"compressedUrn": true,
"rootFilename": "root-design-file.iam"
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}

Phase Views in manifest after RVT model translation, how to detect or suppress?

We have a Revit model where we have configured a single 3D View in Publish Settings. We published that model to BIM 360 and are using Forge to extract the list of 3D Views.
We notice that after the model is translated, the only views available in BIM360 are the views included as set in the Publish Settings in Revit, irregardless of phase, but are under the Phases icon, when we extract the Views from the manifest we also get additional views that were created because some objects belong to different Phases. We don’t seem to be able to distinguish between the different views or see a relationship between different phases of the same view.
Is there a way to do that? or not to translate the additional phase views at all?
The extract below shows us the {3D} view and the Phase Views created “Existing” and “New Construction” using GET
https://developer.api.autodesk.com/modelderivative/v2/designdata/:urn/manifest
Manifest:
Those phased 3D views are from the mater view for each phase, you can suppress them by submitting translation jobs like below:
// POST https://developer.api.autodesk.com/modelderivative/v2/designdata/job
// with `x-ads-force: true` Reuest header
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YWRuZGVtby9ob3VzZS5ydnQ"
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
],
"advanced": {
"generateMasterViews": false
}
}
]
}
}
Note. The generateMasterViews option in BIM360 Docs is turned on by default and the translation job will be submitted automatically while the model was uploaded to Docs managed bucket successfully, currently.
Note 2. Triggering any translation jobs yourself on the models of the BIM360 Docs will consume extra Forge Cloud Credits. So, you have to use it carefully at your own risk.
Ref: https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/#body-structure

Open a model in custom viewer from BIM 360

I've extracted the the folder content from bim 360:
Result
{
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:huksL2JVQ2Gy4n4EEOY9Mg",
"attributes": {
"displayName": "4storeyy.ifc",
...
"data": {
"sourceFileName": "4storeyy.ifc"
}
}
},
}
The id (URN) is the same as the one in the URL when I view it in BIM 360.
If I use the URN in my custom viewer, it does not work.
https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpkbS5saW5lYWdlOlgyOU1ydUhZUWJXV21feE1MNndLZmc=/manifest gives not found
Is this how you should do it if you want to read the model from BIM 360? If so, what can am I doing wrong?
Or do I need to run download it, translate it before reading it?
Yes you will need to translate the model before being able to load it on Viewer.
Simply follow the usual steps here except that you shouldn't need to download and upload the model again and can use the ID on wipprod for translation straight away.

Autodesk Forge retrieve/update custom attributes

We are using BIM360 docs and we have defined several custom attributes to tag those files uploaded into the docs folder. Now we are having trouble to get those custom attribute using forge API, projects/:project_id/items/:item_id endpoint only returns those default attribute like file name/description but for custom attributes it's not included in the response, neither can i update those custom attributes use PATCH to update those custom attributes.
Does Autodesk Forge API support getting/updating custom attributes?
The attribute node I got from the item API looks like this:
"attributes": {
"name": "somefile.rvt",
"displayName": "somefile.rvt",
"createTime": "2018-08-02T18:16:59.0000000Z",
"createUserId": "creatorID",
"createUserName": "usercreate",
"lastModifiedTime": "2018-11-01T10:46:20.0000000Z",
"lastModifiedUserId": "userid",
"lastModifiedUserName": "username",
"versionNumber": 1,
"extension": {
"type": "versions:autodesk.bim360:Document",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:Document-1.0"
},
"data": {
"processState": "PROCESSING_COMPLETE",
"viewableId": "id",
"viewableGuid": "id",
"viewableName": "Existing",
"sourceFileName": "somefile.rvt"
}
}
}
Thanks.
AFAIK, the information of folder/file is provided by Forge Data Management API, this API is used as a common access to many different Autodesk SAAS app like A360 Personal, BIM 360 Team, Fusion Team (formerly known as A360 Team), BIM 360 Docs.
Unfortunately, since the custom attributes are specified only for BIM360 Docs(correct me if I am wrong), so the Folder/Item API of Forge Date Management does not provide that information yet. I am also checking with our engineering team to see if any other information, or this could be a good API request, will update this if I got more information.

Monitoring progress of extraction job of file in a bucket?

I want to monitor the progress of an extraction job of a file stored in a bucket.
I've gone through the Webhooks API documentation, and if I understood everything correctly, the events only work for files stored in a folder, so it can't be used with a bucket. Please correct me if I'm wrong.
So, besides polling the GET :urn/manifest endpoint in the Model Derivate API, and assuming the Webhooks API can't be used with a bucket, is there any other way to monitor the progress of an extraction job?
Thanks.
Webhook now supports the Model Derivative event extraction.finished. This type is exactly used in the scenario of translating model of the bucket.
This is a blog on the API. I copied it as a reference on SO:
https://forge.autodesk.com/blog/introducing-webhook-model-derivative-api
Webhook now supports the Model Derivative event extraction.finished, so your app can be notified when translation job finishes.
To use it, (1) create a hook specifying a scope.workflow:
{
"callbackUrl": "http://bf067e05.ngrok.io/callback",
"scope": {
"workflow": "my-workflow-id"
}
}
And (2) when posting a translation job, specify the misc.workflow:
{
"input": {
"urn":
"dXJuOmFkc2sub2JqZWN0czpv...."
},
"output": {
"formats": [{
"type": "obj"
}]
},
"misc": {
"workflow": "my-workflow-id"
}
}
With my test, the workflow can be guid of your WebHook.The post body from Forge will tell you which file is translated and its urn, location etc.
Hope it helps.