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?
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:
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)
uidoc.Selection.SetElementIds(elem_id_L)
untested
Thank you,
The script you posted returns an error, but it has definitely pointed me in the right direction.
yeah,
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 ElementId
s, which is more generic than the list implementation)