Dynamo "is input" through pyRevit

Hi, I’m trying to run a Dynamo script through a pyRevit pushbutton.

Is there any way to utilise the dynamo “is input” function (in this case a string) or am I stuck using the Dynamo Player?

You dynamo script needs to be autonomous:

  • Inputs need to be handled by the script (with a data-shapes multiple inputs form for example)
  • Outputs same thing

if the script in question is the one from the screen capture that would look like this in pyrevit:

from pyrevit import revit, DB, forms
from pyrevit.framework import List

doc = revit.doc
uidoc = revit.uidoc

elem_id = forms.ask_for_string(default="123456", prompt="Enter element ID", title="Select by ID")
elem_id_L = List[DB.ElementId](elem_id)

untested :point_up:

Thank you,

The script you posted returns an error, but it has definitely pointed me in the right direction.

probably need to set the text to integer first:

elem_id_L = List[DB.ElementId](int(elem_id))

Like I said, I haven’t tried it, and cannot test it now

I would also simply try

elem_id_L = [ElementId(int(elem_id))]

If I understood IronPython correctly, the generics are needed when initializing an empty list, e.g my_list = List[type](), but if you pass in a list of objects of the right type, it should recognize the python list as a valid list (In this case the SetElementIds requires an ICollection of ElementIds, which is more generic than the list implementation)