def isolate_elements(list_el_ids, view):
"""Isolate Provided Elements in a View by using .Excluding method in FEC."""
List_isolate_el_ids = List[ElementId](list_el_ids)
hide_elems = FilteredElementCollector(doc, view.Id)\
.Excluding(List_isolate_el_ids)\
.WhereElementIsNotElementType()\
.ToElements()
hide_elem_ids = [el.Id for el in hide_elems if el.CanBeHidden(view)]
List_hide_el_ids = List[ElementId](hide_elem_ids)
view.HideElements(List_hide_el_ids)
with Transaction(doc, 'Isolate Elements') as t:
t.Start()
elements_to_isolate = [doc.GetElement(e_id) for e_id in uidoc.Selection.GetElementIds()]
List_isolate_ids = List[ElementId](elements_to_isolate)
isolate_elements(List_isolate_ids, doc.ActiveView)
t.Commit()