Export IFC model including just isolated elements in 3D view

Export IFC model including just isolated elements in 3D view

evidalpe
Contributor Contributor
1,430 Views
4 Replies
Message 1 of 5

Export IFC model including just isolated elements in 3D view

evidalpe
Contributor
Contributor

I am trying to isolate some elements in a 3D view, and then export that 3D view as an IFC model with just the isolated elements. However, the IFC keeps exporting all the elements in the view. Here it's my code:

// Get elements in 3D view to be isolated  
List<FamilyInstance> familyInstances = new FilteredElementCollector(CurrentDocument, ref3dView.Id).OfClass(typeof(FamilyInstance)).Where(e => e.LookupParameter("TEST_PARAMETER").AsString() == "TEST_VALUE").Cast<FamilyInstance>().ToList();

List<ElementId> filteredElements = familyInstances.Select(fi => fi.Id).ToList();

// Duplicate 3D view
View3D duplicated3DView;

using(Transaction tran = new Transaction(CurrentDocument, "Duplicate View"))
{
  tran.Start();
  ElementId duplicatedViewId = ref3dView.Duplicate(ViewDuplicateOption.Duplicate);
  duplicated3DView = CurrentDocument.GetElement(duplicatedViewId);
  tran.Commit();
}

// Isolate elements in 3D View
using(Transaction tran = new Transaction(CurrentDocument, "Isolate elements"))
{
  tran.Start();
  duplicated3DView.IsolateElementsTemporary(filteredElementIds);
  tran.Commit();
}

// Export IFC model and delete duplicated view
IFCExportOptions ifcExportOptions = new IFCExportOptions
{
  ExportBaseQuantities = true,
  FilterViewId = duplicated3DView.Id
};

using(Transaction tran = new Transaction(CurrentDocument, "Export IFC"))
{
  tran.Start();
  CurrentDocument.Export(Path.GetTempPath(), duplicated3DView.UniqueId + "_isolated", ifcExportOptions);
  tran.Commit();
}

using(Transaction tran = new Transaction(CurrentDocument, "Delete duplicated view"))
{
  t.Start();
  CurrentDocument.Delete(duplicated3DView.Id);
  t.Commit();
}

 

I guess the issue has to be with the IsolateElementsTemporary method, but I don't know how to fix it.

filteredElements is a valid list of elements included in the 3D view I want to export, and I checked that it's right and contains several elements.

0 Likes
Accepted solutions (1)
1,431 Views
4 Replies
Replies (4)
Message 2 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @evidalpe ,

 

Please be aware that the Revit API hardly ever supports any functionality that is not also available in the user interface.

Therefore, if the UI does not support this, the API will probably not do so either.

So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.

So I would suggest first you find out the optimal manual approach and make a note of the IFC Export Options settings you have given.

Next, use the steps mentioned in the below link and set the appropriate export options settings(the IFC export options settings you noted from UI) to Export your files to IFC.

https://forums.autodesk.com/t5/revit-api-forum/ifc-export-options/td-p/9686404 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

evidalpe
Contributor
Contributor

I think my IFCExportOptions are ok. I've tried exporting non-temporary views using the same options and it works.
I guess the issue comes when I export the IFC from an Isolated/Temporary view. There is no way to export correctly the isolated view neither from the UI nor using the API, so the program ends exporting the whole view without taking into account the isolated elements.

My issue (I guess) becomes then a matter of how to isolate those elements in the new view definitively, and not temporarily. But I don't know how to do it or whether is possible.

0 Likes
Message 4 of 5

evidalpe
Contributor
Contributor

@naveen.kumar.t basically I need to know if the following "Apply Hide/Isolate to View" method is exposed in the API, because I can't find it. Or if there is any known workaround to do so.

evidalpe_0-1652279803686.png


That's exactly what I need and it seems to be possible in the UI. I took it from the following question:

Solved: Permanently Hide or Isolate - Autodesk Community - Revit Products

0 Likes
Message 5 of 5

evidalpe
Contributor
Contributor
Accepted solution

Ok I think I just found it. Crazy how I couldn't find it before. Hope the export is correct now.

ConvertTemporaryHideIsolateToPermanent Method (revitapidocs.com)