Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Solved! Go to Solution.