Function takes exactly 2 arguements (0 Given)

Hi,

I’m using Pythin within Dynamo to create some utility routines to speed up my use of Revit.

One error I come acorss a lot is something along the lines of:

TypeError: AddSet() takes exactly 2 arguments (1 given)

AddSet is an example of the error, I sometimes get it with other functions, everytime I look at the API help only one arguement is required - not two as the error states.

I believe this is because I’ve not imported something, but I’m no too sure what and how I can find it out.

Below is my code to create a SelectionFilterElement - this generates the error:

I’d appriciate some advise on whats going wrong…

 # Dynamo
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *


doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
elefound		= UnwrapElement(IN[0])	# A list of elements of a certain category

elefound = elefound.Id

filtlist = List[ElementId]()
filtlist.Add(elefound)

faminfil = SelectionFilterElement.AddSet(filtlist)


#Assign your output to the OUT variable.
OUT = [faminfil]

You havent done the ilist part of the code correctly and you would be better to do something along the below lines or a nother solution is there is a spring package that as a selectinrevit node.

Also double check that the filter selection routine is the right one for you.

 # Dynamo
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *


doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
elefound = UnwrapElement(IN[0])	# A list of elements of a certain category

elefound = elefound.Id

filtlist = List[ElementId](elefound)

faminfil = SelectionFilterElement.AddSet(filtlist)


#Assign your output to the OUT variable.
OUT = [faminfil]

OK, thanks for your help.

I’m still struggling with the use of ilists over the use of a standard list, I can’t really see what the difference is especially as most functions within the API accept lists where as the odd one requires an Ilist.

Also, is an Ilist the same as an Icollection?

Thanks.

@Gui_Talarico actually contributed with an excellent post explaining the different use of the native python list, and the .NET based list. I’ll link it when i get home if you can’t find it. :slight_smile:

Maybe this?

Exactly the one I was thinking of :+1::slight_smile:

Excellent - thanks for your help!