Make filter based on Elevations, not able to select elevation

AukeDoornbos
Explorer
Explorer

Make filter based on Elevations, not able to select elevation

AukeDoornbos
Explorer
Explorer

Hello everyone, i have a problem i can not get my head around. 

 

For some reason i can not get the code below to work (well it works but not how it supposed to) Eith the below code the filter is being made and applied to the view. But there is no category selected (see screenshot) how to i get it so the category elevation is selected in the filter. Hope someone can help me.

 

 

// create list of categories that will for the filter
IList<ElementId> categories = new List<ElementId>();
categories.Add(new ElementId(BuiltInCategory.OST_Views)); //Works but for creating but no categories is selected. I need to select Elevation but categorie is empty now.

// create a list of rules for the filter
Parameter param = null;
IList<FilterRule> rules = new List<FilterRule>();

foreach (View item in new FilteredElementCollector(curDoc).OfClass(typeof(View)))
{
	if(item.ViewType == ViewType.Elevation)
	{
		param = item.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER);
		break;
	}
}

rules.Add(ParameterFilterRuleFactory.CreateNotContainsRule(param.Id, sheet.SheetNumber, false));

//apply filter to view
ParameterFilterElement filter = null;
using (Transaction t = new Transaction(curDoc, "Create and Apply Filter"))
{
	t.Start();
	filter = ParameterFilterElement.Create(curDoc, "_PBT_" + view.Name, categories, rules);
	view.AddFilter(filter.Id);
   
	//set filter overrides
	view.SetFilterVisibility(filter.Id, false);
	t.Commit();
}

 

How it looks when this code is executed:

2019-05-09 08_31_37-Filters.png

 

How it should look in the filter:

2019-05-09 08_32_43-Filters_correct.png

0 Likes
Reply
Accepted solutions (1)
486 Views
3 Replies
Replies (3)

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Auke,

 

Thank you for your query.

 

I assume you have already studied the Revit SDK sample ElementFilter/ViewFilters?

 

Does it not illustrate this aspect of setting up a filter?

 

Best regards,

 

Jeremy

 



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

AukeDoornbos
Explorer
Explorer

I did but i find it sometimes difficult to understand the SDK samples. 

But I took a look again and got the SKD sample working so i also could use debug to see what is does. And found some things i overlooked.

 

Thank you, i have it working now. It was a stupid thing i overlooked in the buildin Parameters, but sometimes it happens.

 

ps. I think i did something wrong with creating the original post. Just do not know what.

0 Likes

jeremytammik
Autodesk
Autodesk

Congratulations on solving it! I am glad the suggestion helped. I did not notice anything wrong with your post...

 

Best regards,

 

Jeremy

 



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

0 Likes