Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hide-unhide linked file in view

2 REPLIES 2
Reply
Message 1 of 3
plaiknst
453 Views, 2 Replies

Hide-unhide linked file in view

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?

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: plaiknst

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
Troy_Gates
in reply to: plaiknst

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community