removing controlled parameters from view templates

image by archi-lab

It’s been a while since I wrote a post on Dynamo workflows, but it has also been a while since I have been using Dynamo for anything. I kind of like to prototype things in Dynamo these days, but not so much rely on it for anything that I want to distribute to a wider user base. This particular workflow was kind of a side effect of something else that I was working on. Originally I was asked to add Graphics Scales to all Viewports (views on sheets). Of course John Pierson has already covered that, and was kind enough to share with me. What I ran into while implementing that though, was the fact that when I added Shared Parameters to the View, all of my View Templates had these two/three parameters checked. My view templates by default took control of these new Shared Parameters. Now, that’s not exactly what I wanted, because my goal was to write custom values to these parameters, so they cannot actually be controlled. That’s how this workflow came about, I needed to un-check them for all View Templates before I could use John’s workflow. Here’s how:

As you can see above it’s pretty straight forward. We collect all Parameter objects. The Element Type for this is called SharedParameterElement. As the name implies, it will work only for Shared Parameters that were added to the project, so don’t expect it to work for system parameters. Once we have the parameters, we isolate ones that we are interested, and get their IDs. Now, using Archi-lab own’s View.GetByType and View Types nodes, we can collect all of the View Templates in the project. Now we do a little Python magic to remove the isolated parameters from view templates. Here’s the code:

IMPORTANT! 

Please remember that messing around with View Templates in Revit will cause views to regenerate. Why does it matter? Well, we are overriding ALL of the view templates here, so most likely we are going to regenerate all or most of the views. The best way to handle that is to CLOSE ALL WORKSETS before using this workflow. Everything will regenerate much faster with worksets closed. Now, to minimize the amount of regeneration, I am checking whether given view template actually has that parameter under control, so that we don’t necessarily touch view templates that don’t need to be updated, but then again, on large projects, and first time you administer this workflow, it will have to regenerate a lot of views.

Enjoy!

UPDATE 09/11/2017:

So apparently you can skip this entire ordeal, if you add the Shared Parameters to the Shared Parameters file, and then set them to be “hidden”. Thanks to John again for sharing: Set Parameter to hidden. 

Leave a Comment