#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 lines = new FilteredElementCollector(doc)
        .Where(q => q is DetailLine)
        .Where(q => q.LineStyle.Id == line.LineStyle.Id)
    uidoc.Selection.SetElementIds(lines.Select(q => q.Id).ToList());

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s