Retrieving Views associated with an Element Id?

Retrieving Views associated with an Element Id?

Anonymous
Not applicable
1,530 Views
7 Replies
Message 1 of 8

Retrieving Views associated with an Element Id?

Anonymous
Not applicable

We can use FilteredElementCollectors to retrieve all Element Ids associated with a view, i.e., FilteredElementCollector(doc, view.Id). Given one of these elements, can we instead programmatically retrieve all the views in which this element is visible? My instinct is "no", both because I didn't see such a call in the Element or FamlyInstance documentation, and because I imagine this would put quite a tax on the DB whenever the a view's graphics overrides are changed. That said, I figure there's no harm in asking 🙂

 

Thanks in advance!

0 Likes
1,531 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Actually, you can retrieve the views an element is on.  That being said,getting the view an element is on has a little problem. For instance, when searching for windows in an front elevation view, it will find windows in the back elevation when the depht of the view is deep enough. In other words, a view is more then what you see 🙂

0 Likes
Message 3 of 8

Revitalizer
Advisor
Advisor

Hi,

 

additionally, think of a furniture element residing inside the building.

It may be "visible" in default {3D} view, but may be occluded by walls, roofs etc.

 

So, in fact, you will not see this element in {3D} at all.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 4 of 8

Anonymous
Not applicable

Thanks both. What is the API call to handle this? I know I can retrieve this information using FilteredElementCollectors on the views of interest, extracting the elements, and filtering on the element I'm interested in...but I'm hoping for something more efficient, e.g., an (Element)e.AssociatedViews property.

0 Likes
Message 5 of 8

Revitalizer
Advisor
Advisor

Hi,

 

there is only a View.IsHidden(Element) method; also, you could check the Category visibility per view: View.GetVisibility(Category category).

But no way to determine the desired relation definitely.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 6 of 8

Anonymous
Not applicable

Thanks again, Revitalizer. The only other possibility I can think of would be to compare an element's bounding box with each view bounding box, probably in combination with checking the .IsHidden property. Determining what qualifies element visibility based on its bounding box coordinates would be the tricky part. Even if it worked, I'm not sure how much of an efficiency gain we'd see from this. I may experiment with this for fun, though.

 

 

Thanks for the brainstorm Smiley Happy

0 Likes
Message 7 of 8

Anonymous
Not applicable

Thank you Remy, for the first encouraging note I have seen on this topic.

What is the trick to finding the view in which an element is 'theoretically' visible?

Hopefully if I can somewhat efficiently find all these views, I could then do a bit of crunching to determine if it is the kind of 'visible' I am looking for.

 

Thanks in advance for your help. A little sample or pseudo-code would be great.

 

Abba Lustgarten

Abba CAD Abba Inc.

0 Likes
Message 8 of 8

Alexandre_Coelho
Participant
Participant

Hello, I'm new to the Revit API, but I needed to solve the same problem and found a property in the element (OwnerViewID). With this property I was able to find the view to which the element belonged.

0 Likes