- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to highlight a list of elements in a View, so I created the following method:
public static void HighlightElementsInView(Document doc, View view, List<ElementId> eIds)
{
OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
overrideGraphicSettings.SetProjectionLineColor(new Color(255, 0, 0));
overrideGraphicSettings.SetSurfaceForegroundPatternColor(new Color(255, 0, 0));
using(TransactionGroup transactionGroup = new TransactionGroup(doc, "Highlight Elements in View " + view.Name))
{
transactionGroup.Start();
if(view.CanBePrinted)
{
foreach(ElementId eId in eIds)
{
using(Transaction transaction = new Transaction(doc, "Highlight Element " + eId.IntegerValue))
{
transaction.Start();
view.SetElementOverrides(eId, overrideGraphicSettings);
transaction.Commit();
}
}
}
transactionGroup.Assimilate();
}
}
This works fine, but when the number of elements is large (e.g. 15000), the process takes ages or the program crashes. Is there a way to optimize this?
I'm kind of missing a method like "SetElementsOverride" that takes a List of elements and only uses a transaction to modify them all.
Solved! Go to Solution.