0

I am creating a plugin for Revit 2019 and want to select all the instances of specific family and type through API. "ElementClassFilter" is available in Revit sdk to filter the elements but I want to display all instances of same type in blue lines. I have filtered the specific type through "ElementClassFilter" but looking for how to select them in revit through API.

The following code is for filtering elements of specific family and type.

ElementClassFilter filter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.WherePasses(filter);
var query = from element in collector where element.Name == "Single-Standard" select element;

List<FamilyInstance> familyInstances = query.Cast<FamilyInstance>().ToList<FamilyInstance>();

But I want to show all instances of same family and type in the following image

"Window: Single-Standard" image

2
  • as I understand, you want to have the selection in the revit interface, once you press your plugin button? like an automatic selection plugin? Commented Apr 24, 2019 at 6:13
  • Yes, I want selection in revit interface. Commented Apr 24, 2019 at 6:17

1 Answer 1

1
UIApplication UIapp = commandData.Application;
UIDocument UIdoc = UIapp.ActiveUIDocument;
Document doc = UIdoc.Document;

FilteredElementCollector elementCollector = new FilteredElementCollector(doc);
elementCollector.OfClass(typeof(FamilyInstance));

Selection sel = UIdoc.Selection;
sel.SetElementIds(elementCollector.ToList().Select(o => o.Id).ToList()); //User selection

This is a simple example to how to set the user selection. For mor info of revit Selection class you can visit this link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.