#BILTNA2018 Wish granted: Select detail lines by Line Type

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());
}

 

2 thoughts on “#BILTNA2018 Wish granted: Select detail lines by Line Type

Leave a comment