I’m looking for a bit of assistance with the below thread:
The method shown by Konrad is clear enough to follow, but it relies on the viewport type being in use (within the project) and using indexes to filter the element to obtain the element with the desired parameter value.
What I’m after is setting my viewports to a specific type by name “No Title”. Is there a way to list the value types like we can do with Family.Types Node?
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc).OfClass(ElementType).ToElements()
viewportTypes = []
for e in collector:
p = e.get_Parameter("Title")
if not p is None:
if p.AsValueString()=="M_View Title":
viewportTypes.append(e)
#Assign your output to the OUT variable.
OUT = viewportTypes
I was testing on a quite old Revit version. I think in a newer API you might wanna use LookupParameter instead of get_Parameter…Sorry about that.
As of the IN part - nothing should be connected
I have modified the code as required. Getting information from the python script node but its erroring on the Element.Name as the output from the python are strings.
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
fec = FilteredElementCollector(doc).OfClass(ElementType).ToElements()
vpt = []
names=[]
for f in fec:
p = f.LookupParameter('Title')
if not p is None:
vpt.append(f)
names = [Element.Name.__get__(i) for i in vpt]
OUT = vpt, names
This modification was for test purposes only…to see what kind of parameter values you have in your project. It seems that you should look for “View Title” string instead of “M_View Tilte” (as was in my code)…
so you can try this one…hope it works now for you
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc).OfClass(ElementType).ToElements()
viewportTypes = []
for e in collector:
p = e.LookupParameter("Title")
if not p is None:
if "View Title" in p.AsValueString():
viewportTypes.append(e)
#Assign your output to the OUT variable.
OUT = viewportTypes
I was using this method originally, but I wanted to see the available options in the viewport types. This option requires there to be a viewport with the desired View Title Type to be in use in order for it to be used.
@Kulkul - Yes I pasted your code within the ‘Python Script’ Node. See below:
@maciek.glowka - That did it. Thanks so much. I have provided my graph below in case it is usual for another member of the forum.
The completed graph’s function is to:
Select all Sheets within Active Document and insert [Legend] at a point indicated.
It then takes these newly added viewports and runs it through the second tier of the script. Changing their viewport types from the default to my preference of “No Title”