How to set Viewport Type?

Good morning! I’m hoping someone can solve my mystery! I have a relatively simple script that assigns a specific viewport type to a certain set of views. It works 90% of the time. The trouble is, it doesn’t work 100% of the time and I can’t understand why. Sometimes I just have to run it several times and then it works. Sometimes I have to swap the viewport type then run the script and it works.

This might be tricky to test since it is tailored specifically for our model set-up, but any feedback is welcome. (Elements.FilterByName is from the Clockwork package).

Thank you!

Bot - Set Viewport Types for 3D Views.dyn (11.6 KB)

Looks like the viewport has 2 parameters called Type that are in different orders in the list (and apparently different at every run).

This is me hacking Python together but, so far, it seems to work;

import clr
# Import Element wrapper extension methods
import Revit

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

#The inputs to this node will be stored as a list in the IN variable.



for i in viewPort:

#Assign your output to the OUT variable
OUT = newId

Where do you put this python script…can’t get it to work

@Arno_De_Lange search for a Python Script node and copy the code above.

I get how we get the Python node in, but i can’t get what we feed it… how does it fit in the flow…

Post a screenshot of what you have tried so we can help with your current roadblock.

so the element.SetParameterByName… doesn’t give an error but it doesn’t change the viewport either

pythonscript is the script above in this thread


@Greg_McDowell, no Python needed. We can set the appropriate parameter by using the BuiltInParameter nodes from Archi-lab.

@Arno_De_Lange, This should do the trick:

Ps. The issue with the OOTB parameter nodes are as stated above. There are multiple parameters with the same name, and they are stored in a ParameterSet so an unordered collection. Please use BIP to get the “right” parameter every time.


I got the nodes in … and the get BipParameterName and the first time i got the pulldown menu and could select intstance|type. but there where two in the list. so the script didn’t work probably have the wrong one.

but now i don’t get the pull down menu any more

That node outputs a string: “ELEM_TYPE_PARAM” so you can just hard code that instead. Of course it would be easier to get the actual thing to work.

1 Like

Works perfect thank you Konrad

What did you do to get this working?

the parametername input was a string called ELEM _TYPE_PARAM in my case

Your using a string node and at what place did you put?
Or did you use a code to place it in to replace the Get BipParameter Name?Capture

Anthony, did you figure this one out? can’t read your picture it has no headers

No, I did not figure it out yet. Been going through and recreating the views and schedules that were an issue. It would be awesome if it just made all views, schedules, etc just into one so we could delete all the rest out.

I have tried different ways but I’m not sure what to do. Capture1

Actually I figured this out getting this to work. I am trying to delete the viewport types that have been brought in through the insert view from file command. Instead of having to find it manually and delete the view or schedule to get rid of the additional families in a template or project.

You are getting a NAME (string, text) and feeding it into the Element input. Please feed it an element (one, 1).

This works with @Greg_McDowell Python code:

1 Like

Where the node Viewport.ViewName does come from? I could not find it.