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: 

Make filter based on Elevations, not able to select elevation

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
AukeDoornbos
396 Views, 3 Replies

Make filter based on Elevations, not able to select elevation

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

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: AukeDoornbos

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

Message 3 of 4
AukeDoornbos
in reply to: jeremytammik

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.

Message 4 of 4
jeremytammik
in reply to: AukeDoornbos

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

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community