Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I am making a selection tool but ran into a problem with visually indicating the selected element.
If possible I would like to avoid using PickObjects.
The current code follows these steps:
- PickObject in a while loop
- After PickObject I would like to select the element but PickObject clears this selection.
- New solution override element graphics but this doesn't quite work (I don't know why).
Below you will find the code I currently have:
private Document _doc;
private UIDocument _uidoc;
using(var subtx = new SubTransaction(_doc))
{
subtx.Start();
var overrideHighlight = new OverrideGraphicSettings();
overrideHighlight.SetProjectionLineColor(new Color(0, 0, 255));
var overrideClear = new OverrideGraphicSettings();
var elementList = new List<ElementId>();
var exitSelection = false;
while (!exitSelection)
{
try
{
var element = _doc.GetElement(
_uidoc.Selection.PickObject(
Autodesk.Revit.UI.Selection.ObjectType.Element,
new SelectionFilterByFamily("FamilyName")));
if (!elementList.Contains(element.Id))
{
elementList.Add(element.Id);
_doc.ActiveView.SetElementOverrides(element.Id, overrideHighlight);
_doc.Regenerate();
}
else
{
elementList.Remove(element.Id);
_doc.ActiveView.SetElementOverrides(element.Id, overrideClear);
_doc.Regenerate();
}
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
exitSelection = true;
}
}
subtx.Commit();
}
If possible I would like one of two solutions:
- Have the PickObject method not clear the selection.
- Override graphics but display them properly.
Solved! Go to Solution.