RPS - Selection.SetElementIds() method

Hey guys I have just started to use RPS and iam facing the issue at the end of the script it says

SetElementIds() takes exactly 2 arguments (1 given)
but on the API docs it expects only one

image

here is my script

#Import Autodesk stuffs
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import iron python packages
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)



app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document

#get All category in the Document

AllCategory = doc.Settings.Categories
ModelCategory = []
ModelCategoryName=[]
for x in AllCategory:
    if x.CategoryType == CategoryType.Model:
        ModelCategory.append(x)
        ModelCategoryName.append(x.Name)

CategoryDictionary = dict(zip(ModelCategoryName,ModelCategory))

#Create Forms to record User Inputs

from pyrevit import forms
Selection=forms.CommandSwitchWindow.show(ModelCategoryName,message='Pick type category')

index=ModelCategoryName.index(Selection)
SelectedCategory=ModelCategory[index].Id

# collect element of selected Category

Collector = FilteredElementCollector(doc)
items= FilteredElementCollector.OfCategoryId(Collector,SelectedCategory).WhereElementIsNotElementType().ToElements()

ParameterName = forms.ask_for_string("Enter the parameter Name")

OperatorList=[" Equals to","Less than","Greater than",]

Operator = forms.CommandSwitchWindow.show(OperatorList,message='Choose Operator to compare')

CompareWith = forms.ask_for_string("Enter the a value to compare")

out=[]

if Operator == "Equals to":
    for a in items:
        a.LookupParameter(ParameterName).AsDouble() == CompareWith
        if True:
            out.append(a.Id)
elif Operator == "Less than":
    for a in items:
        a.LookupParameter(ParameterName).AsDouble() < CompareWith
        if True:
            out.append(a.Id)
elif Operator == "Greater than":
    for a in items:
        a.LookupParameter(ParameterName).AsDouble() > CompareWith
        if True:
            out.append(a.Id)

from Autodesk.Revit.UI.Selection import Selection
from System.Collections.Generic import List as CL

finalout=[]

for a in out:
        finalout.append(a.Id)

Sel = CL[ElementId](finalout)

Toselect = Selection.SetElementIds(doc,Sel)

Can Someone help me figure this out

Edit : This is the error That is returned by RPS

image

Hi @saju_autodesk,

This question is not very Dynamo related, and is probably better suited at the Revit API discussion forum (https://forums.autodesk.com/t5/revit-api-forum/bd-p/160).

I can’t test this right now, but you can try this:

image

1 Like

I agree wholeheartedly. If the use case 100% outside of Dynamo then the Revit API forums or the RevitPythonShell forums (assuming they have one?) are a better home for issues like this.