Active selection with Grasshopper script within a pyRevit button

Hi,

I am working on creating my own pyRevit pushbutton. The button runs a Grasshopper script, which uses the current selection in Revit. It seems that the script executes too quickly before it retrieves the current selection. Does anyone have experience with this or a solution to this issue?

Hi Cas, I don’t have pyRevit loaded but if you can post an example of what you are trying to do as well as the Revit and Rhino version targeted we can try and help.

Hi Japhy,

Sorry for my late reply.
I made a simple pushbutton with the pyRevit folder extensions. The script is attached below.
In this case, the script should use the active view (the case I described above should use the active selection). In both cases, the pushbutton (Grasshopper script) does not interact with Revit.

This is just a simple script that creates break lines for my detail view.

I don’t know if you are familiar with the extension in pyRevit, but you can create a folder structure like the one below. With pyRevit, you can select this folder structure, which creates a tab and button on the Revit ribbon. The last folder should contain the GH script named as “script” and a 32x32pixel png icon named “icon”

“C:\AppData\RibbonName.extension\TabName.tab\PanelName.Panel\ButtonName.pushbutton”

Revit version: 2024
Rhino: 7

afbreeklijn.gh (7.2 KB)
icon

1 Like

Is Rhino.Inside.Revit loaded when you run the command?

In the RiR options you can set it to start Rhino when starting Revit.

Yes, Rhino is active when pressing the button.

What exactly are you trying to select? Ehsan is saying this should work. Thanks

The first script operates only within the active view, generating break lines at the detail crop view.
I’ve also created a similar script that duplicates selected lines at a specified distance.

This highlights that the current selection functionality doesn’t work when using the PyRevit option. While I’m working on more complex features, ensuring this fundamental aspect works is essential for further progress and scripts/buttons.