It would be nice if we could right click on a specific linetype and “select all instances” in view instead of having to select everything and then filter them out.
public void selectAllLineStyle()
{
Document doc = this.ActiveUIDocument.Document;
UIDocument uidoc = this.ActiveUIDocument;
DetailLine line = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select detail line")) as DetailLine;
// if you want only the lines in the current view, add "doc.ActiveView.Id" to the FilteredElementCollector
List<CurveElement> lines = new FilteredElementCollector(doc)
.OfClass(typeof(CurveElement))
.OfCategory(BuiltInCategory.OST_Lines)
.Where(q => q is DetailLine)
.Cast<CurveElement>()
.Where(q => q.LineStyle.Id == line.LineStyle.Id)
.ToList();
uidoc.Selection.SetElementIds(lines.Select(q => q.Id).ToList());
}
Does not work in Revit 2019. There are 2 mistakes in lines:
List lines = new FilteredElementCollector(doc)
…
.Cast()
fixed