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: 

Filtering elements visible in view - problem.

1 REPLY 1
Reply
Message 1 of 2
pawel.soltysiak
1672 Views, 1 Reply

Filtering elements visible in view - problem.

Hello everyone!

 

I am trying to select elements visible in certain Plan using FilteredElementCollector constructed with :

 

public FilteredElementCollector(
	Document document,
	ElementId viewId
)

 

this work like a charm, but only in situation where plan does not represent one of many levels. In that situation, it also collects elements form plans of levels lying underneath level of filtered ViewPlan. Same situation happens in Revit application - when in select element and change active view to plan of level above it is still underlight and active. Does anyone have an idea how to simply improve approach with using FilteredElementCollector to collect elements that are visible only in selected plan ?

 

Many Thanks,

Paweł

 

1 REPLY 1
Message 2 of 2
Lucavox
in reply to: pawel.soltysiak

Hello,

 

The method you use collect all the elements that are visible in the selected plan. So you need to filter elements using a filter passing the plan level as variable. Something like this:

 

 

Element my_view = document.GetElement(view_id);
 
FilteredElementCollector elements = new FilteredElementCollector(document, view_id);
 
//take elements from the view level
List<Element> my_level_elements = elements.toelements().where(e=>e.levelId == my_view.levelId).ToList();

 

 

It would work.

I haven't tested the code.

 

Regards,

Luca

 

 

 

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