Select All In-Place Elements in View

In-Place elements are really annoying in Revit, and yet nearly all projects have a few of them. So it might be useful to select In-Place elements visible in view with the snippet below

Select In-Place In View

This script will select all visible In-Place elements in the Active View.

# -*- coding: utf-8 -*-

# ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗
# ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗
# ╩╩ ╩╩  ╚═╝╩╚═ ╩ ╚═╝ IMPORTS
#==================================================
from Autodesk.Revit.DB import *

#.NET Imports
import clr
clr.AddReference('System')
from System.Collections.Generic import List

# ╦  ╦╔═╗╦═╗╦╔═╗╔╗ ╦  ╔═╗╔═╗
# ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║  ║╣ ╚═╗
#  ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES
#==================================================
doc   = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app   = __revit__.Application

# ╔═╗╦ ╦╔╗╔╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
# ╠╣ ║ ║║║║║   ║ ║║ ║║║║╚═╗
# ╚  ╚═╝╝╚╝╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ FUNCTIONS
#==================================================
def get_in_place_elements():
    """Get In-Place Elements in Active View."""
    collector = FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(FamilyInstance).WhereElementIsNotElementType().ToElements()
    inplace_families = [x for x in collector if x.Symbol.Family.IsInPlace]
    return inplace_families

# ╔╦╗╔═╗╦╔╗╔
# ║║║╠═╣║║║║
# ╩ ╩╩ ╩╩╝╚╝ MAIN
#==================================================
if __name__ == '__main__':
    all_in_place     = get_in_place_elements()
    all_in_place_ids = [i.Id for i in all_in_place]

    # Modify Revit UI Selection
    new_selection = List[ElementId](all_in_place_ids)
    uidoc.Selection.SetElementIds(List[ElementId](new_selection))

⌨️ Happy Coding!
Erik Frits