I've been able to show all objects, but through a rather convoluted way.
Here's how I did it.
I run my script. It collects the ID's of every object that causes the an error. With that collection, I do the following:
Make a transaction, make a CreateIsometric 3D view, name it. (Code mentioned above).
Then I unhide all the elements in my "error" collection.
view33.UnhideElements(PILIDList);
Then I commit the transaction.
Just to make this work for now, I use the visibilityCategory method to turn on all the Walls. I want this to turn on all BIC's, but for now, I just have it for walls to get this dumb script done.
Util.visibilityCategory(doc, categories, view33, BuiltInCategory.OST_Walls);
(While I have you, how can I include all categories, not just the walls, without making some sort of loop?)
Onward,
I set the new 3D View as active:
uiApp.ActiveUIDocument.ActiveView = view33;
Then I make a new transaction.
Then I collect all the elements in the view:
FilteredElementCollector CGM = new FilteredElementCollector(doc, view33.Id);
ICollection<ElementId> hh2 = CGM.ToElementIds();
List<ElementId> hh2List = (List<ElementId>)hh2;
Then I go through all the elements in a loop to determine if any object in the main view object collection is in my error loop. If it is, I have a subroutine to return if it exists, and to skip it. If it doesn't, then it hides the object using the HideElements method. Since HideElements only takes a collection or list, then I have to make a temporary list in the loop to perform the hide operation.
if (IsInListElementID(PILIDList, hh2List[jkl]) == false)
{
//hide
try
{
List<ElementId> hh2ListPre = new List<ElementId>();
hh2ListPre.Add(hh2List[jkl]);
view33.HideElements(hh2ListPre);
hh2ListPre.Clear();
}
catch { }
}
else
{
//show
}
Perhaps I could make a "RemoveOffendingIDsFromList()" subroutine so I could do the HideElements method, but for now, this works.
After all this, I use the UnhideElements to "show" all the objects that were in my "error" list.
view33.UnhideElements(PILIDList);
I commit this and it shows all the elements in the 3D View. Or, it hides all the elements.
Either way, all or nothing doesn't help me. I need a 3D view showing ONLY the objects in my "error" list. Using these API's is like pulling teeth.
Here are my questions:
Could my "error" objects be sub-objects, which when you hide/show the parent object, it hides everything underneath it regardless if the sub-object is "unhided?"
Why isn't UnhideElements showing my objects?
Could my "error" objects not be able to hide/show via the API? They are "error" objects because it does not allow me to modify parameters on them.
My error objects happen to be parts of walls. When I "show" the category of OST_Walls, does that "show" all the elements under a 3D wall, or does it just show parts of a wall, thus my "error" objects won't show up regardless?