The node in red gives me 1 pop up and I can select either doors or windows or both.
The custom node has the same code but it gives me two pop-ups. The first to select doors and the second to select walls.
I want the custom node to function the same as the python node (just one pop-up with a choice of categories as input.
The code is adapted from some John Pierson wrote:
import clr
import msvcrt
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
sel1 = uidoc.Selection
obt1 = Selection.ObjectType.Element
category_list = IN[0]
message = "Click on the elements of type" + str(category_list) + " you want to open in the Revit window.\n\n***Then press the ESC key to finish.***"
if category_list != "RESET":
TaskDialog.Show("Select your elements!", message)
class CustomISelectionFilter(Selection.ISelectionFilter):
def __init__(self, allowed_categories):
self.allowed_categories = allowed_categories
def AllowElement(self, e):
if e.Category.Name in self.allowed_categories:
return True
else:
return False
def AllowReference(self, ref, point):
return True
msg1 = 'In your Revit window, pick " + str(category_list) + then press the ESC key to finish.'
out1 = []
flag = True
while flag:
try:
el1 = doc.GetElement(sel1.PickObject(obt1, CustomISelectionFilter(category_list), msg1).ElementId)
out1.append(el1.ToDSType(True))
except:
flag = False
if len (out1) == 1 :
OUT = out1[0]
else:
OUT = out1
else:
OUT = "Moose"
I tried list levels with the custom node (just in case) but that didnāt have any effect.
How do I make the custom node behave like the Python one?