Display a pop up window in Rhino when the solution is completed

I have a long calculation and I would like the user to be warned when the calculation begins and when it ends. I made a component in VB to handle the events “GH_Document.SolutionStart Event” et “GH_Document.SolutionEnd Event”.
I made a component in Python to display a box in Rhino.
But i don’t know how link the 2 components.



You can simply call System.Windows.Forms.MessageBox.Show() in your OnEndSolution Sub.

I managed to replicate this using C#, however :

  • it is EXTREMELY annoying to have the message pop-up at each component insertion, wire modification
  • it doesn’t work when inserting component from the search bar.

SolutionEnd.gh (1.7 KB)

I’d suggest two alternatives :

  • If your calculation ends with one or several meaningful results, plug them as the input to a component that only displays the message, with the input as tree. This component will therefore run a single time, after all relevant data is calculated. You wouldn’t need event handlers.
  • Define a component that schedules a new solution of the entire file, based on a button press, and after that solution, displays the message.

RecomputeAndMessage.gh (5.5 KB)


Thank’s a lot magicteddy for your quick response. The SolutionEnd.gh is effectively annoying.
I had already tested the first of the two alternatives with a component in Python. But the message appears at approximately half resolution.
I have two branches on my diagram can you precise when you says with the input as tree. I tried with a And gate but with no success.
I tried the RecomputeAndMessage.gh solution but with the same issue. The message appear at the half of the computation.
Thank you again for your help.

It’s weird that the message is displayed in the middle of a solution, because it’s triggered by the SolutionEnd event… The fact that it’s exactly the middle makes me think the definition computes twice then ?

As for the first solution, the idea is as follows. Let’s assume your definition converges to two parameters (points, here for the example) which are your final results. What you can do is plug those in a single component (VB/C#) with the input in Tree Access. After trying it, a faster alternative is actually to flatten everything and only take the first element as a “trigger”.

This component does not have to use this input at all, it’s just to be able to trigger it once.

It seems to work as intended here…


RecomputeAndMessage.gh (10.1 KB)


Yes, I also think that the calculation is done twice because now with the first solution I have a message in the middle of the calculation and one at the end.
But when I pass on the components I have “This component ran once”

Hello magicteddy,
I think I found why the calculation was done twice.
Originally I wanted to make two files that had to communicate with each other through a data input-output module and I had kept it on the diagram. I removed it and haven’t had this problem since.

On the other hand, I have a problem with the C# module to display the message.
I have two main branches in my diagram.
The first called “Setting 2D” must retrieve user information in real time with sliders and during this time the other branch “Calculation 3D” is blocked.
As I don’t want the message to appear each time I do a recalculation in the “Setting 2D” branch, I didn’t put the message module on the end modules of this branch.
But despite everything when I recompute (no event management anywhere) the message is still displayed.
I tried by removing the recompute code from your example and breaking the link between list item and C# Script and hitting F5. The message still appears.

Anyway, thanks again for your help.

This is because the event handler has already been told to show the message. Removing the component does not remove the event.
Delete the recompute C# script, keep the one at the end (after List Item), linked to your second branch. Then restart Rhino, you should be fine.

1 Like

I dont understand, I tried starting from a new file (not to conserve the event) and putting 2 counters which represent the two branches.
On the branch with the longest calculation I added a C# module by adding the code “System.Windows.Forms.MessageBox.Show”.
I added the metahopper module which allows to deactivate the counter module of the branch which takes the most time.
If I launch a recompute with F5 and the counter deactivated, the message is still displayed.
Component desactivate test 1.gh (8.6 KB)
So I added the message module in the deactivation selection.
Component desactivate test 2.gh (8.7 KB)

This is due to GH’s expire solution behaviour.
If you deactivate the counter, this will trigger downstream components, even if there is no data provided, they would still expire, hence the message is displayed.
Same thing if you hit F5, this expires all components and recomputes everything, including that component.

Your second solution is indeed the way to go. This will prevent the message from showing if the second counter is modified, and when activated, since the message is expired last because it’s the most downstream component, it will always appear after your second (slow) counter is computed. However, if you recompute the whole file, it is not guaranteed the message will appear at the end of the solution. For instance if you add another counter and leave it alone (don’t wire it), and hit F5 you’ll see the message appear before that third counter expires.

1 Like

OK. Thank’s a lot for your help magicteddy !