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: 

Invisible items being tagged

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
floretti
260 Views, 2 Replies

Invisible items being tagged

Hi all, thanks for reading.

 

I'm tagging a specific set of fixtures using a multi-category tag and the IndependentTag.Create(), which creates tags nicely on my view.

 

The odd part is that I can be inside any other view which doesn't show those fixtures (as they are on another level) or even inside a sheet, and if I run my command again the tags are created and hosted by the view but they are obviously not visible.

 

Is there a way to prevent that from happening? The most obvious way I can think of is comparing the level of the view against the level of the fixture and only create the tag if they match but that's definitely not ideal as sometimes the family can be hosted on other levels (or floors for example) and visible in the view, which means they still need to be tagged.

2 REPLIES 2
Message 2 of 3
jeremy_tammik
in reply to: floretti

So the end result of this is a tag in one view tagging an element that is not visible in that view, is it? Do you know whether it is possible to achieve the same strange result when working with the model manually through the end user interface? I.e., select the fixture in one view, switch to another view in which it is invisible, and tag it there?

  

To just address this with a brute force approach without understanding the underlying reason, similar to your suggestion on matching the level, but a little bit more specific, it would be handy to determine programmatically whether a given fixture element is visible in a given view. There has been some discussion on determining all elements visible in a view:

  

  

One of the simplest things you could try out is to pass the view element id to a filtered element collector and check whether the fixture is returned or not:

  

https://www.revitapidocs.com/2023/6359776d-915e-f8a2-4147-b31024671ee1.htm

  

Constructs a new FilteredElementCollector that will search and filter the visible elements in a view.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 3
floretti
in reply to: jeremy_tammik

Thanks, Jeremy. Great ideas.

 

So the end result of this is a tag in one view tagging an element that is not visible in that view, is it?

Correct but since the element is not visible the tag is not either. I just knew it was there because my script was reporting the tag as created. Also, I could select a tag in another view and use the "Select all" and the count would show them, including their host view (via the Revit Lookup).

 

Do you know whether it is possible to achieve the same strange result when working with the model manually through the end user interface? I.e., select the fixture in one view, switch to another view in which it is invisible, and tag it there?

Unfortunately I couldn't manage to achieve the same result in the UI as tags don't need a selection to be made for them to be placed. You just hover over an item and the tag comes up, which doesn't happen if the item is not visible.

 

Fortunately passing the view Id to a FilteredElementCollector worked very well (so far). I haven't done extensive testing but if I happen to find any issues with that approach I'll report back in this thread.

 

For now I'd say that approach is very simple and effective so thanks again for the idea.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community