How to create and control View Filters

Did creating a new View Filter or the ability to switch filters on/off get resolved as a Dynamo node as noted here Turn off the visibility of a View Filter ? I can’t seem to find it and I have most packages loaded.

This question comes on top of many questions previously asked relating to this subject but for one of those (known unknown) reasons, I can’t find a solution built in Dynamo.

There seems to be a bit of bush beating to get an answer, but for a simple node that easily switches the visibility on/off, seems difficult to find, considering the “view filters” feature is one of the most productive tools in Revit.

I thank Einar Raknes who provided the information for the attached graph at Override element graphics in selected view this allows control of the Visibility Graphic Overrides for Filters. What I’m finding is, it is difficult to find a node that includes a switch to switch the visibility on and off, although it seems to be embedded in the Python code attached in the .dyn file, I’m not a coder and don’t wish to be. I can see the inputs in the Python code, but what the inputs refer to exactly, is a bit of a mystery to me (unknown unknown’s). However when I see how beautifully some coders make dynamo sing, I know there are beautiful ways to present information that eliminates second guessing, isn’t this the purpose of Dynamo ?

Apply GraphicOverrides to Filter.dyn (24.1 KB)

“Mod-Stairs” is my unique filter name, you would have to set up a similar filter name for the attached graph to work.

How much more straight forward would a Filter node showing the following, for someone who has no python skills, be to assemble ?

See Jeremy James Graham’s Visual Style Select node.

Previous posts on this topic ;

Create and apply list of filters to single view using Python

Setting Filter Visibility

Python - Get View Filter Rules - ParameterFilterElement.GetRules

Create and add view filter (ParameterFilterElement)

Listing Revit View Filters by the Views where they are used

1 Like

To my disappointment, I have to answer my own question, which is frustrating as I see there are many posts that pose similar questions with minor differences to serve, in most cases, the needs of the poster, and they still get answered. All questions posed should be answered, even if it is a link to a previous post, as the linked post, may or may not have been obvious to the poster of the question asked, or indeed anyone who picks up on a post, otherwise it is a deadend.

The advancement of any tool or process relies on continued improvement, either by the individual knowledge, or the process or tool itself. I believe the posts I have put together are made on broad topics, not only to benefit myself, but also the larger community. I have always included the graphs to make it easier to share the results and understanding.

I have mentioned before, I do not wish to code, I wish the functionality in the node, for the benefit of Dynamo and Dynamo users. In this post I have made a small modification to the code behind the node, I renamed to Visibility Switch for View Filters, which works for one view, my question now is, how can you make it work for a list of views ?

ViewFilters_Test.dyn (21.7 KB)

Before you attack the community for not paying attention to your posts, remember that anyone that takes time away from their job to answer a community question is likely doing so on their own time. I’m not sure where you are from, but I noticed that your question was posed 5 days ago, which for many of us was Thanksgiving Day - a national holiday in the USA that consists of the intake of massive amounts of food, watching of football for 3 straight days, and general avoidance of anything remotely related to our day jobs…so a gentle bump might have been enough to get it on someone’s radar. That said - your taking the time to research the issue and find related topics and work your own solution is often better than someone answering your question outright - you likely learned a thing or two in the process (if you are modifying code then you’ve learned something…don’t fear Python- it’s really pretty easy even for non coders (like myself)).

Your dyn solution you uploaded cannot be viewed by anyone else as the “visibility switch for filters” custom node you modified only exists on your machine. You need to copy/paste the guts of that custom node off to the side in the main dyn so that anyone that wants to help can see the logic and reverse engineer/fix/modify to provide a solution.

5 Likes

Nothing better than 3 days of football, couch surfing and massive quantities of food to de-stress the working week, I very much appreciate any time given to answer any question, but you’re right a gentle bump should have been the preferred approach, frustration got the better of me. Maybe the powers can offer a better remuneration for product development, which of course, relies on both the poser of questions and the responder to those questions.

But I thank you Ben, for your reply, here is the code behind the node, it was original called “Add View Filters to View” from the Bakery Collection.

from the forum originally
import clr

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *

dataEnteringNode = IN

filters = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
visOrNot = IN[2]
output = []

TransactionManager.Instance.EnsureInTransaction(doc)
for x in filters:
try:
view.SetFilterVisibility(x.Id, visOrNot)
output.append(“Filter switched”)
except:
output.append(“Filter failed to switch”)

TransactionManager.Instance.TransactionTaskDone()

OUT = output

So there are two ways you could try to make that work for a list of views.
1 - “Use List.Map”
Place a List.Map node, Unwire the “TargetView” port of your “Visibility Switch” node, and wire the “doneOrNot” into the “F(x)” port of List.Map. Then Wire the List of views into the list port of “List.Map” (leaving a port open on some custom nodes converts them to a function that can then operate on a list via list.Map)

2 - modify your code some more so that it expects a list of views

See Below

Hello Ben,

I think I followed your instructions, however something is astray.

There are two parts to what I’m trying to do, one apply a graphic filter to a view, and then the second part is to control the visibility of that view, i.e. either On or Off. We don’t have to be trapped in the process that I started out, it was my attempt at trying to achieve that outcome, if there is a better way, I’ll gladly accept that, I just could find a node to do it. However you will see I can control multiple views with a different graphic filter (in this case color). The second part is then to control the visibility of the filter for a particular view (ie on or off). I was able to do that for a single view, but now after following you’re instructions there is something amiss for me. I have included the .rvt sample file and updated graph.

Filters-Dynamo.rvt (2.1 MB)
ViewFilters_Test.dyn (26.8 KB)

TransactionManager.Instance.EnsureInTransaction(doc)
for v in views:
out=
for x in filters:
try:
v.SetFilterVisibility(x.Id, visOrNot)
output.append(“Filter switched”)
except:
output.append(“Filter failed to switch”)
output.append(out)
TransactionManager.Instance.TransactionTaskDone()

1 Like

Did you do both #1 and #2? I only meant to do one or the other (Either modify the custom node code or run the original custom node thru list.Map).

I have not moved my office over to 1.2 yet for a number of reasons, so i don’t have access to the View.Filters node (so i can’t test…)

If you open up the Custom node, copy the contents (Ctrl+C) then Paste (Ctrl+V) into your main script, you should be able to see if there is an error in your Python Script and what line that error is happening at. (i might be able to diagnose it from that error message and a picture of the full Python Script)

I know you don’t want to learn to code, but there is not a node for everything under the sun, and it sucks being at the mercy of what others have done or not done (or will do for you). I started out as a Node Only type of user, but i quickly became frustrated at the lack of nodes that could do what i needed to, so i had to learn Python and Revit API enough to get done what i needed. And i did not learn by reading a book or taking a class - i learned by opening up custom nodes (ClockWork, Archi-Lab, and SpringNodes) and reading their code line by line until i understood what was happening in there. Trust me - it will be tough in the short term and will feel like taking a step backwards, but it will greatly enhance your overall capabilities and eventually land you far ahead of where you’d be if you stuck to using only nodes and other people’s packages that were likely developed for their needs - not yours.

4 Likes

@Ben_Osborne +1

1 Like

Ok, so I’m slowing starting to understand the philosophy attached to the development of Dynamo, and we’re all in the sandpit and sometimes sand gets in your eye, or is that smoke, but I am most pleased it has roots in Monty Python – what a disguised blessing.

Ben, I take on board all that you have offered, and the funny thing the post may have bogged down in Thanksgiving and bobbled around with football, but the solution maybe more akin to football than you first think, as there are a whole lot of running costs in football, there are a whole lot of rules to the play, and there is a whole lot of comradery in the team. All the positions are occupied by individuals who want to win, or even achieve a double win outcome. I do understand my understanding will most likely be increased by learning Python, however I do not need to do that to be an effective player, much like the differences between a guard and a wide receiver.

I’m interested in the use of Dynamo, whilst there are other players who are interested in the use of Python and also Dynamo/Python players. Whilst I’ll agree the No Free Lunch (NFL) rule should apply, my own reluctance to “learn” Python should not be taken as a reluctance to put in an effort to find a solution in Dynamo. I think the problems I have come across are of a broad interest to the community as a whole, and seek solutions couched in those terms. All I can do is put out the question, and then it’s up to the “strong safety” or the (SS) to protect the team, but we won’t mention the war !

The last .dyn file I posted did not produce any errors, it just didn’t control the visibility filter switch on/off for a list. The view.filters came from a solution posted by Einar Raknes which controls the likes of color and lineweight.

I did note that the visibility switch did work when the view name was just a single line (1) Name = South as opposed to the list of view names (2) where it didn’t work. And as I said before all I’m looking for is a node which controls the Visibility/Graphic Overrides Filter, which everyone needs, whether they know it or not.

does anyone knows how i can show the information from the csv on my revit model? i have tried something but not having the results i need yet.

MANIPULATE DATA FROM THE CSV.dyn (157.3 KB)