A few years ago, I was seeking a way to convert a list of elements into the current Selection (to use for "Copy To Level" or "Copy To Current View". My particular situation is post-program from a "Smart Filter" that allows the user to select multiple family names/types, not just "Structural Framing (girder)" as in Revit's built in filter.
The solution HAD BEEN:
SelElementSet SelSet = uiDoc.Selection.Elements;
SelSet.Add(Element1);
SelSet.Remove(Element2);
The problem is, this no longer seems to be working in Revit 2016 (+). Running the code with these lines now causes a program ending error:
"Revit encountered a System.MissingMethodException: Autodesk.Revit.UI.Selection.SelElementSet Autodesk.Revit.UI.Selection.Selection.get_Elements();" (I assume the line "SelElementSet SelSet = uiDoc.Selection.Elements" invoked .get_Elements)
I am able (at the start of my program) to obtain the current selection using
Selection All_Guys = uiDoc.Selection;
and from this I can convert everything to Ilist or List etc., based on using Tree nodes to remove particular categories/family names/family types. But then I need to be able to convert this all back to the current selection (hopefully using SelSet.Remove(Element2) for the elements that do not match the filtering), and every time I use SelElementSet, I get the program ending error above.
Note that in September, 2014 I asked a SIMILAR question. I know there are powerful arbiters on this site that are itching to mark questions as already answered -- this goes under a category "previous answer no longer works". Please read the question more carefully and don't have it thrown out just because you have the power.