Select several categories with Rhythm's "Isolated Pick Model Elements(ordered)"

I have gotten a lot of use out of Rhythm’s Isolated Pick Model Elements(ordered) and recently I’ve thought up a new use for this node.

However, I noticed that it really only allows one type of category per run. With the graph I’m trying to create however, I’m needing three: mechanical equipment, pipe fittings and pipes.

I’ve been playing around with the Python script inside the node and gotten so far that I think the part that needs change is:

while flag:
try:
	el1 = doc.GetElement(sel1.PickObject(obt1,CustomISelectionFilter(IN[1]), msg1).ElementId)
	out1.append(el1.ToDSType(True))
except:
	flag = False
	
	OUT = out1

Specifically I feel the part

CustomISelectionFilter(IN[1])

is the part I think is causing the “trouble”, as the IN[1] asks for a string with the name of the desired catagory. I am not sure, but I have not yet succeeded by making this code work by changing this part.

Thanks in advance!

#Copyright(c) 2017, john pierson
# @60secondrevit, http://sixtysecondrevit.com
#Thanks to Dimitar and Troy Gates for Guidance
#and this blog http://pythoncvc.net/?p=116
#Edited by Sean Page, 12/9/2020 to accept list of categories
import clr
import msvcrt

clr.AddReference("RevitAPIUI")
from  Autodesk.Revit.UI import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
TaskDialog.Show('Isolated Selection','Pick elements in desired order, then press ESC to finish')
sel1 = uidoc.Selection
obt1 = Selection.ObjectType.Element

class CustomISelectionFilter(Selection.ISelectionFilter):
	def __init__(self, nom_categorie):
		self.nom_categorie = nom_categorie
	def AllowElement(self, e):
		if self.nom_categorie.Contains(e.Category.Name):
		#if e.Category.Name == self.nom_categorie:
			return True
		else:
			return False
	def AllowReference(self, ref, point):
		return true
msg1 = 'Pick elements in desired order then press ESC to finish.'
out1 = []
flag = True

while flag:
	try:
		el1 = doc.GetElement(sel1.PickObject(obt1,CustomISelectionFilter(IN[0]), msg1).ElementId)
		out1.append(el1.ToDSType(True))
	except:
		flag = False
		
		OUT = out1

5 Likes

Well, you’re my hero today.

Thanks a ton!

1 Like