Message 1 of 4
Optimize performance while creating 3DViews and Filters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm creating an add-in that creates views and add filters (which i also create via the api). On average, there are around 1000 views and 1000 filters added to each view. I found that CreateIsometric takes longer than duplicating the view using ActiveView.Duplicate(ViewDuplicateOption.Duplicate) so i decided to use Duplicate to create my views. However, adding the filters using AddFilter takes a lot of time. Is there any way to optimize my code? Here is a snippet of my code:
foreach (string tempName in allTempNames)
{
Element CreatedView = doc.GetElement(ActiveView.Duplicate(ViewDuplicateOption.Duplicate));
Autodesk.Revit.DB.View newView = doc.GetElement(CreatedView.Id) as Autodesk.Revit.DB.View;
newView.Name = tempName.Remove(phase.LastIndexOf('*'));
}
FilteredElementCollector viewCollector = new FilteredElementCollector(doc).OfClass(typeof(View3D));
List<View3D> views3d = viewCollector.ToElements().Cast<View3D>().Where(x => x.IsTemplate == false).ToList();
foreach (View3D view in views3d)
{
if (allList.Any(a => a.name== view.Name))
{
foreach (LOE lo2 in allFilters)
{
view.AddFilter(lo2.filter_id);
}
}
}
Thank you in advance,
Mohamad.