Get views by name by genius loci order of views

Hello everybody, I am having some trouble with a couple of nodes, specifically when trying to get views or sheets by name given, in this example I have a CSV file with the names of some views, the problem is when the “get views by name” node detects the view name, the order of the list is wrong, and the parameters I am trying to set from the csv file then get all wrong… any ideas on how to make the node to respect the csv order?? the same problem I have with the “get sheets by name” node

thank you!!!

This is what is happening, shouldn’t these boolean be all true??

Here is a modified version of the code contained within that node (adapted from work done by Daniel Woodcock):

import clr
from RevitServices.Persistence import DocumentManager
from Autodesk.Revit.DB import FilteredElementCollector, View

# Part of script from Clockwork
inputdoc = UnwrapElement(IN[2])
if inputdoc == None:
	doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance":
	doc = inputdoc.GetLinkDocument()
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
	doc = inputdoc
	doc = None

def tolist(obj1):
	if hasattr(obj1, "__iter__"): return obj1
	else: return [obj1]

names = tolist(IN[0])
cont = tolist(IN[1])
cont = cont[0]
outList = []

views = {}
views_all = FilteredElementCollector(doc).OfClass(View)
# Create a dictionary associating Names to Views
# e.g. {'3D View 1': View3D}
for view in views_all:
	if not view.IsTemplate:
		views[view.Name] = view

for name in names:
	for key in views.keys():
		if cont:
			if name in key:
			if key == name:

OUT = outList

In the original script, all of the views were in the outer loop and the user-defined names were on the inner loop. This effectively made the order of the output match the order of creation of the views. If you look at the Element Ids in green, you can see that they are ordered numerically (32, 9948, 174614, 41301, 43000, etc.).


thank you!! I will give it a try!

You can also do this with a == and a Filter.ByBoolMask node.

In the screen cap I posted before, I did it, the result was that not every view was going to be modified

It seems to work smoothly, thank you!

That is correct, the order was the ID numbers, in fact, I ended up making two routines, one exporting the views with the ID number, modify the parameters in open spreadsheets, then reorder the cells by the ID numbers and finnally setting the new parameters… now it should be nicer… thanks!

1 Like