Select an element with a button

Hi everyone,

My goal is to create different PyRevit buttons to chose a date for all the elements I’ve selected. Some elements on Monday, others on Tuesday, ect…

I found an easy way to select elements to modify one of their parameter with Dynamo.
Now, I’m trying to create a PyRevit button to use it. But when I launch it, it only works for the preselected elements, I can’t select new one.
I guess I need to create an entry/input but I don’t find how to do it ?

Could someone give me an advice ?
Thanks a lot :slight_smile:

if you plan on running a dyn script from your button, you need to create the ui (datashapes) or the python script necessary whithin the dynamo script itself.
If you approach the problem from a pyRevit perspective with a file, based on a tool I did to set active workset from selection:

from pyrevit import revit
from pyrevit import forms

with revit.Transaction('Set param value'):
    if  forms.check_selection():
        selection = revit.get_selection()
        # taking for granted you have more than one element selected
        for elem in selection:
                print("Cannot change param value for Element with ID: {}".format(elem.Id))

I haven’t tried it, but I am pretty sure it is 99% accurate and working.

Hi, thanks for your answer. Here is what I wrote :

I’ve placed it as a but it doesn’t work (nothing happened), did I make something wrong ?
I’m sorry, I know how to use Dynamo but I’m really low level when you are talking about Python :smiling_face_with_tear:

Do I need to create a Python script box in my Dynamo script to replace the first box I’ve place in it ?

I am guessing the data type of your parameter/value is the issue
Your Day parameter is of what data type?
Tried it with the ‘Commentaires’ builtin param and it works as expected

Maybe you didn’t understand what I’m trying to do.

For example, I’ve select 2 parts (elements), launched the script while dynamo is opened and it worked. Then I close the script, and launch the same script with the PyRevit button where I included the
I can’t select new parts to give the same parameter data. It only refresh the 2 first parts I already gave the parameter data

I understood well, I just porposed a solution with a script only solution
That would require that you have only the file in each button

Like I mentioned, if you want to go on with the Dyn file, you need to use some sort of UI or prompt to get selected element OR a piece of python script to get the current selection in real time.
In your original selection, the first node is a static selector.

Ok I understood, I think I’ll be able to do that :slight_smile:
Thanks for your help !