I tried it with different methods, but always get error messages or the function does not.
public static void SichtbarkeitSchalten(Document Doc, string Endung, string Filter, List<View> Ansichten)
{
using (Transaction trans = new Transaction(Doc, "Import ein- oder ausblenden"))
{
trans.Start();
foreach (View ansicht in Ansichten)
{
foreach (Category kat in Doc.Settings.Categories)
{
if (kat.Name.EndsWith(Endung) && kat.Name.Contains(Filter))
{
ansicht.SetCategoryHidden(kat.Id, !kat.get_Visible(ansicht));
}
}
}
trans.Commit();
}
}
When I try to control the visibility of the category, the following error message always comes.
How can I control visibility?
Dear Stefan,
Thank you for your query.
Have you explored the database using RevitLookup?
I think you should. Snoop the Db and check the import instances.
I have a vague recollection that each imported file generates two elements.
One of the two is the one you need, and the other one is not.
Maybe the second one is causing the error.
What happens if you simply catch the exception and ignore it?
Better, of course, would be to determine which exact element you need and skip the other one.
Ah yes, one of them may be the element type and the other the element itself, as in this sample:
http://thebuildingcoder.typepad.com/blog/2012/02/remove-imported-jpg-and-bmp-images.html
I hope this helps.
Please let us know how you end up solving this.
Thank you!
Best regards,
Jeremy
You could try getting the linked elements first and then hide the category using the Element.Category property.
Can't find what you're looking for? Ask the community or share your knowledge.