Creating Filter Rules - List Manipulation

Hey all, so I’ve been attempting to create a series of filter rules that will apply to to named views in this project. Each of our parts has a parameter named “Pour ID”, with a specific ID associated with each unique part (W-201, BS-101, etc.).

I’ve managed to write a script to make a “Does Not Contain” rule for each one, but when I run the script, it takes each rule and runs again for each Pour ID over and over inside the rule.

For instance, the filter “Not BS-302” should only have the rule “Pour ID does not contain BS-302”; however, it currently has “Does not contain BS-101, Does not contain BS-102, Does not contain BS-201”. It’s as if the script is rerunning the list of pour numbers each time it makes a filter – I only want to associate one filter with one rule/Pour ID.

I’ve tried several methods including indexing and trying to select the underlying element, to no avail. I’ve traced the source of the error back to the FilterRule.ByRuleType node, but I can’t figure out how to get these to only use the single appropriate Pour ID parameter.

Any help would be much appreciated!

Script:

Output (every filter has these same 3 rules):

lil bump

1 Like

Use List.GetItemAtIndex to select one Pour ID value per filter creation. It still will fill out all three rule options but with the same value. I could be wrong but it seems like the Parameter.FilterElementByRules node doesn’t allow for the creation of only one rule.


Filter With GetItemAtIndex

That’s strange because it works for me.

Have you tried setting your lacing to longest, or setting the value input to level 1?

3 Likes

Oops! @Nick_Boyts is right! Set lacing to longest on your ParameterFilterElement.ByRules node

1 Like

@awilliams something wrong here ?
I think you have to set lacing to longest on FilterRule.ByRuleType node then connect the list output port of List.Create node to the value input port of FilterRule.ByRuleType node. .

2 Likes

Thank you all very much! That was exactly it. I appreciate the help, this forum really is a great resource!

1 Like

cnealy can you post your results. I’ve been fighting with the exact same thing for a week and found this post today. I’ve tired all the different post suggestions with lacing giving me the same results either way. I’m also having a problem that the value is never stored in the filter.

Here is with one workset selected and handful of categories selected.


Results look like this :

With two worksets selected and lacing set to short:


Results look like this:

With two worksets selected and lacing set to long:


Results look like this: Filter Create 2 Workset Selected Lacing Long Results

I’m sure like everything I’ve learned about Dynamo when it doesn’t work, it’s something simple I’m overlooking. I second your appreciation for this forum as an amazing source of nice and bright people willing to help develop other skills.

Of course, see my full script below:

The premise is that it reads any element of “category:Part” in the model (our company uses Parts to make pour drawings for concrete), reads the value of the shared parameter Pour ID that we made, filters it by unique ID, removed the empty ones, and creates a filter where you apply it, turn off the visibility, and all parts that don’t have the requisite Pour ID are hidden.

For example, if you want to only see Base Slab 101 (BS-101), you make a filter called Not BS-101 (where the Pour ID does not contain BS-101) and turn visibility off. My script makes one filter for each unique Pour ID.

Hope this helps!

1 Like

Finally got it sorted out. Lacing was killing me but it was all in the part where you added the "Not " to the name that helped keep the list down to the number of items in the list. I used “” and it worked just fine.

Thanks everyone on this one. Now to move on to applying the filters & create different colors for each one.

1 Like

Check out the OverrideGraphicSettings.ByProperties node in the Revit OOTB dropdown (Revit->Filter->OverrideGraphicSettings). I did something similar with a script I wrote. Combine this with View.SetFilterOverrides and by playing with some of those inputs, you should get to where you need to be.

When you worked on your script did you set it up to batch process the filters you created? I was messing around today with the both of those and was just now figuring out how I can send lists to the View.SetFilterOverrides node. When we start a project we can over 100 electrical panels that we usually manually create the worksets, then filters for. I was working it up to read those panel names from a spreadsheet and take care of all that manual work for us. The part that I haven’t got ironed out yet is how to create different colors for each of the filters. This is what I’m playing with right now.

Create Filter Color Overrides

Duh I see where I was messing up with converting to a string the output of my user selection.

The colors seemed to be random and seems to work ok.

3 Likes

HI @awilliams
do you have any solution if i want to make 2 filter at the same time.
Filter A … rule greater X
Filter B … rule greater Y
(same parameter) …
Thanks

Don’t use Cross Product lacing. Shortest should work.

1 Like

try to sort the filter by the parameter and see what happens?
Surprisingly every time you run the script it replace the one you created before using the same script…
anyone knows why???

Sorry for resurrecting an old thread, but I’m wondering if you’ve had the same problem I’m seeing.
I had a very similar graph that worked fine - until I upgraded Dynamo to 1.3.3.
Now my Parameter.FilterElementByRules node returns only nuls
No other changes. Just upgrading from 1.3.2 to 1.3.3
See this thread:

Hi all,
I am trying to do exactly what you re doing here but I can’t find FilterRule.ByRuleType node !! I have looked in all packages but I really can’t find it !
Would you have any explanations ?

Thank you very much !!!

Hello. Please make a new post when you have a different problem (ex. finding a node by name) instead of reviving an old/solved post. It helps to keep this place organized and for others to find an answer if they have the same problem. The FilterRule.ByRuleType is an OOTB (out of the box) node, meaning it comes standard with Dynamo, not in a package.

Hi @kennyb6,

You can find this node in Dynamo 1.3. I dont know why but it is not with dynamo 2.0…