Collect Views not on Sheets

Collect Views not on Sheets

Anonymous
Not applicable
1,016 Views
5 Replies
Message 1 of 6

Collect Views not on Sheets

Anonymous
Not applicable

What is the fastest way to generate a list of Viewplan that are not placed on sheets?

0 Likes
Accepted solutions (1)
1,017 Views
5 Replies
Replies (5)
Message 2 of 6

aignatovich
Advisor
Advisor

Hi!

 

I think the simplest and most efficient way to achieve this is to do something like this:

var parameterFilter = new ElementParameterFilter(ParameterFilterRuleFactory.CreateEqualsRule(new ElementId(BuiltInParameter.VIEW_REFERENCING_SHEET), string.Empty, false));

var filter = new LogicalAndFilter(new ElementClassFilter(typeof(ViewPlan)), parameterFilter);

col = new FilteredElementCollector(doc);

var views = col.WherePasses(filter);
0 Likes
Message 3 of 6

Anonymous
Not applicable

@aignatovich some views that are placed on sheets does not have referencing sheet. so this will still include some views that are already on a sheet

0 Likes
Message 4 of 6

aignatovich
Advisor
Advisor

Okay, so, find all Vieports, then create a hashset from ViewId property of each viewport, then collect all viewplans and check each view plan id not in the created hash

Message 5 of 6

Anonymous
Not applicable

that might be it, still looking for other solution...but thanks

0 Likes
Message 6 of 6

aignatovich
Advisor
Advisor
Accepted solution

It seems, it is also quick, simple and efficient.

This is an iron python version (I use it for quick test, I'm too lazy to open visual studio, create a new solution...):

clr.ImportExtensions(System.Linq)
col = FilteredElementCollector(doc)

viewports = System.Collections.Generic.HashSet[ElementId](col.OfClass(Viewport).Select(lambda x: x.ViewId))

plans = FilteredElementCollector(doc).OfClass(ViewPlan).Where(lambda x: not(viewports.Contains(x.Id) or x.IsTemplate)).ToList[ViewPlan]()

lookup(plans)
0 Likes