Convert Specific Revit View to IFC Using Forge Model Derivatives - autodesk-forge

Is there a way to translate only a specific view to IFC using the Forge Model Derivatives API? More specifically, is there a way to make it so "only export elements visible in view" were checked in the Revit export settings with a particular view selected?

To enable Export only elements visible in view, you need to the following:
Create a new IFC Export Setup Option, and check Export only elements visible in view, then give it a name to save it in the RVT file
Save changes to the RVT file
Update the modified RVT model with your own IFC export option to your Forge bucket
Submit a translation via POST job and specify your IFC export option name in the advanced.IFCExportOption like below:
{
"input": {
"urn": "{YOUR_RVT_BASE64_URN}"
},
"output": {
"formats": [
{
"type": "IFC",
"views": [
"3d"
],
"advanced": {
"IFCExportOption": "{YOUR_IFC_EXPORT_OPTION_NAME}"
}
}
]
}
}

Related

Autodesk Forge Viewer is not rendering SVF derived from IFC

IFC model has been uploaded and translated to SVF.
the problem is reproduced on https://autodesk-forge.github.io/forge-tutorial-postman/display_svf.html. The viewer is rendering forge logo indefinitely. The console shows an error:
"TypeError: undefined is not an object (evaluating 't.children.length')"
We are experiencing this since Tuesday, 26 Oct, 2022 06:45 AM (GMT).
This is the body of the Translate Job Post API:
{
"input": {
"urn": "{{t4_ossEncodedSourceFileURN}}"
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d", "3d"
],
"advanced": {
"conversionMethod": "modern",
"buildingStoreys": "show",
"spaces": "show",
"openingElements" : "show"
}
}
]
}
}
The same model is successfully presented when translated to SVF2.
We tested this executing multiple scenarios using multiple models.
Using postman collections, both versions with signedcookies and without show the same behavior.
In our system , we are translating models to SVF and downloading derivatives to serve those from our own servers. The same behavior is noticed there. We are using forge-server-utils version 8.3.4 for download
Also, vscode-forge-tools Visual Studio Code extension shows the same behavior.
Models translated before the date indicated above are rendered correctly.
Kindly asking for help, this has a big impact on our service.

Object Export: Hidden entities of model are getting exported (they shouldn't get exported)

Hi we are trying to export a saved view from the forge viewer.
When trying to export a view with hidden entities we find that the hidden entities do not get removed from the export and the entire model gets exported as it is.
We also tried doing this in postman by only giving the dbIds of entities visible in the model. The results were same, entire model got exported instead of only the non-hidden entities.
We are doing this using the forge model derivatives API- https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/translate-to-obj/
To extract geometry in OBJ you can follow this : Extract Geometry
As you can see, you can specify dbids you want in your extract.
After the extraction is done, check the manifest and you will get all OBJ files with the list of extracted dbids like this :
{
"modelGuid": "b90bbb37-d60e-412c-aedc-bf8c049f0dc7",
"urn": "urn:adsk.viewing:fs.file:URL_SAFE_URN_OF_SOURCE_FILE/output/geometry/b576231b-9684-3609-8fa0-1221a424a77c.mtl",
"role": "obj",
"guid": "fed3c1b1-3c99-34d1-81f1-79f6fea72576",
"type": "resource",
"objectIds": [
4,
5
],
"status": "success"
}

How can I find Revit document derivatives URNs in BIM360 Docs using the Forge Data Management API

I have some Revit files stored in a BIM360 project. I am trying to visualize those files inside Forge Viewer. Now Forge Viewer won't work directly with Revit file/documents, but require the 'urn' of a translated file, in 'svf' format.
I could transform my Revit file into the 'svf' file using the Forge Model Derivative API, but that consume some credits, and I shouldn't be able to do this because when uploading a Revit file into BIM360, the translation is happening already there.
I was wondering then, how do I find out the 'urn' of the underlying 'svf' file for my Revit document ?
I found few resources helping there, when browsing the content of my BIM360 folder, or checking the versions of my Revit document using Forge Data Management API, I should be able to access a derivative object in the response which represent the derived model that can be used by the Forge viewer.
https://forums.autodesk.com/t5/bim-360-api-forum/connecting-forge-viewer-with-bim-360/td-p/6742779
However for me, there are no derivatives object in the API response, see below a sample of the API response (I have obfuscated some data for security purpose):
{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.XXXXXXXXXXXXXXXXXXXX?version=1",
"attributes": "#{name=139200.33_Amenities Building_R21.rvt; displayName=139200.33_Amenities Building_R21.rvt; createTime=2021-09-03T04:24:18.0000000Z; createUserId=XXXXXXXXXX; createUserName=Holmes Consulting; lastModifiedTime=2021-09-03T04:28:02.0000000Z; lastModifiedUserId=XXXXXXXXXXXX; lastModifiedUserName=XXXXXXXXXX; versionNumber=1; storageSize=19808256; fileType=rvt; extension=}",
"links": "#{self=; webView=}",
"relationships": "#{item=; links=; refs=; downloadFormats=; derivatives=; thumbnails=; storage=}"
},
I am using the API call as used in the link I provided above:https://developer.api.autodesk.com/data/v1/projects/:project_id/folders/:folder_id/contents
Why is it that my response contains so little data ?
First thank Eason for contributing.
Since my derivatives object was empty I tried to directly use the 'urn' of my object version.
When listing all my folder documents using the folder get content API method mentioned in my issue, I get all the documents in the 'data' item array and all their versions in the 'included' version array. We need to use the document version id to build the urn. See my sample below:
"included": [
{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.l9pc9re6QOmeEVHvTCTlIQ?version=1",
"attributes": "#{name=139200.33_Amenities Building_R21.rvt; displayName=139200.33_Amenities Building_R21.rvt; createTime=2021-09-03T04:24:18.0000000Z; createUserId=XXXXXX; createUserName=XXXXXXXX; lastModifiedTime=2021-09-03T04:28:02.0000000Z; lastModifiedUserId=XXXXXXXXXXXX; lastModifiedUserName=XXXXXXXXXXXX; versionNumber=1; storageSize=19808256; fileType=rvt; extension=}",
"links": "#{self=; webView=}",
"relationships": "#{item=; links=; refs=; downloadFormats=; derivatives=; thumbnails=; storage=}"
},
Now the id has to be base64 encoded. I am using https://www.freeformatter.com/base64-encoder.html to encode the id urn:adsk.wipprod:fs.file:vf.l9pc9re6QOmeEVHvTCTlIQ?version=1. Beware the result will be dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmw5cGM5cmU2UU9tZUVWSHZUQ1RsSVE/dmVyc2lvbj0 which is not valid in my JS code to load the document in the Forge Viewer, because of the /. It needs to be replaced with a _. So eventually the bit of JS that load my document into the Forge Viewer looks like this:
var documentId = 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmw5cGM5cmU2UU9tZUVWSHZUQ1RsSVE_dmVyc2lvbj0x'; //139200.33_Amenities Building_R21.rvt
Autodesk.Viewing.Initializer(options, function() {
var htmlDiv = document.getElementById('forgeViewer');
viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv);
viewer.start();
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
function onDocumentLoadSuccess(viewerDocument) {
// Choose the default viewable - most likely a 3D model, rather than a 2D sheet.
var defaultModel = viewerDocument.getRoot().getDefaultGeometry();
viewer.loadDocumentNode(viewerDocument, defaultModel);
}
function onDocumentLoadFailure() {
console.error('Failed fetching Forge manifest');
}
});
Please find it in the id value of relationships.data.derivatives. For example,
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkVueWtrU3FjU0lPVTVYMGhRdy1mQUM_dmVyc2lvbj0x"
},
// ...
},
Or check this line: https://github.com/Autodesk-Forge/learn.forge.viewhubmodels/blob/nodejs/routes/datamanagement.js#L155
const viewerUrn = (version.relationships != null && version.relationships.derivatives != null ? version.relationships.derivatives.data.id : null);

Room object in Revit files

I followed the instruction in the link below to extract Room objects from Revit models:
https://forge.autodesk.com/blog/new-rvt-svf-model-derivative-parameter-generates-additional-content-including-rooms-and-spaces
I made the changes as instructed and tested the sample Revit file (rac_basic_sample_project.rvt). But, still I don't see the rooms or the viewables (phases). Below is fhe request I post. Am I missing anything?
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YzQ4ZDUxNDNhMDRiNDAxNmI3ODYxY2NlMzQ2ZDkyNjdfZmFjaWxpdHlfOTUvZWIyYzMzNDgtNDAxYS00ZjQ3LTgwM2EtMjM1OGYwYmI0YjY2LnJ2dA"
},
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "svf",
"views": [
"3d"
],
"advanced": {
"generateMasterViews": true
}
}
]
}
}
I just tested the feature and I can see the room data:
The JSON payload seems ok, so try checking the following things:
Make sure you use the x-ads-force header (explained in the blog post you linked to); if you had already processed your Revit model before, triggering a new Model Derivative job would not do anything unless you force the translation
Try using another design (and from a newer version of Revit if possible); in my screenshot I'm using one of the official samples for Revit 2020, although I remember being able to get the room data from older samples as well
The room data is only available in certain "viewables" so make sure you're looking at the right one; for my sample project, for example, the room data is not available in the "{3D}" viewable but it is available in the "Working Drawings" viewable

Define IFC Mvd on posting translation job

On translation of RVT file to SVF, I also want to post a job to translate and download an IFC file. Opening that IFC file after translation, it seems to use CV1 - Coordination View 1, which is a very old Model View Definition (hardly in use anymore and only for IFC2x3). If I export same RVT file in Revit 2016 with newest IFC exporter downloaded, choosing CV1 as an option, the file size of the IFC file translated from Revit is half the size of that from Forge. Is there a way to specify which MVD to use for the IFC translation using Model Derivative API, as it is in Revit (CV2, COBIE, IFC4 RV/DTV)? Since it seems that Forge uses the Revit IFC exporter, I would anticipate this be an option, but so far I have not succeeded finding it.
2019 Update
Just got informed, the issue REVIT-125299 has been resolved according to our engineering team. So, please try to submit the job body like below, use IFCExportOption instead, then you will obtain an IFC exported with the specified export setting. Cheer!
{
"input": {
"urn": "{{base64URN}}"
},
"output": {
"formats": [
{
"type": "IFC",
"views": [
"2d",
"3d"
],
"advanced": { //!<<< export options start
"IFCExportOption": "IFC4 Design Transfer View"
} //!<<< export options end
}
]
}
}
The old
After checking with our engineering team, Forge MD has supported to set IFC export options up like in Revit. For example,
{
"input": {
"urn": "{{base64URN}}",
"compressedUrn": false,
"rootFilename": "{{Filename}}"
},
"output": {
"formats": [
{
"type": "IFC",
"views": [
"2d",
"3d"
],
"advanced": { //!<<< export options start
"exportSettingName": "IFC4 Design Transfer View"
} //!<<< export options end
}
]
}
}
IFC exporter will try to seek for the saved export settings in your uploaded RVT based on the exportSettingName. If there is no matched setting, it will use IFC2X3 by default as I experience.
But there is a issue related to this feature, the output might not matched with the export settings, it has been logged as request id REVIT-125299 in our internal case system to make our team to allocate time to investigate. Apologies for any inconvenience caused.
However, you can sent the request id to forge.help#autodesk.com in the future to track updates. Thank you~
P.S. The above code sample might be changed in the future, please follow with the official documents: https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/