Toast message after running graph

Hi Guys,

Has anyone gotten Toast messages to work in Dynamo for Revit?
I would like to give a notification after a graph is completed with some stats but I really dont like the aesthetics of a dialog box, which im currently using. It just looks like an error in my opinion…

I’ve seen @GavinCrump do toastmessages in pyRevit but i cant find an example anywhere to do this in Dynamo with a Python Script node

This isn’t a literal toast message, but you can use the notification center in Revit if you want:

# Load the Python Standard and DesignScript Libraries
import sys
import clr

from Autodesk.Windows import *
from Autodesk.Revit.UI import *
from Autodesk.Internal.InfoCenter import *

result = ResultItem()

result.Title = IN[0]
result.Category = "Dynamo"
result.Timestamp = IN[1]

ComponentManager.InfoCenterPaletteManager.ShowBalloon(result);

# Assign your output to the OUT variable.
OUT = result
9 Likes

Thats much much better than my error dialog!
I’ll use this for now thank you :slight_smile:

Leaving the topic open to see if someone has worked out how to get toast messages in Dynamo :slight_smile:

1 Like

It should be doable, but you have to reference windows libraries and I am not huge on using python.

1 Like

How come?

This sounds like a fun challenge.

I usually have a pop up or two (made with winform) that tells the user what’s about to happen, and requires some input…

Then when the script is run I have a final pop up saying… “script finished… it did xyz… blah blah blah” or “script failed because xyz” …

I have found that 99% of people don’t read any of the information though. :person_facepalming:

2 Likes

I do all of my development in c# as that is more “built-in” to Revit and (in my opinion) a better programming language. :innocent:

But I see the appeal of python and I do use it some.

2 Likes

I hope you’re sitting down… I wish i could use Javascript for all my Dynamo graphs/ jsRevit plugi (hehe) plugin… It’s the only language i used a ton. It comes easy to me, as opposed to C#.

1 Like

Hey the graph you made has been loading for half an hour, i could have done this faster manually!
There’s a popup open on their third monitor waiting for approval…

In all seriousness though. Yeah mostly popups and dialogs just get ignored by the less tech savvy. In this case i made a graph that places openings in walls automatically wherever the walls clash with ducts from linked models. I just want to show an update 'found X clashes, placed X openings" :slight_smile:

1 Like

Well… you could do that in a pop-up…

Gather the info and just put it into the string information.

I wrote a load of help documentation to go with all the scripts…
They don’t get read either. People prefer to ring me to ask. :person_facepalming: :person_shrugging: :space_invader:

1 Like

Yeah thats what i’ve been doing but Toast notifs just look so much nicer :sweat_smile:

I wrote a load of help documentation to go with all the scripts…
They don’t get read either. People prefer to ring me to ask. :person_facepalming: :person_shrugging: :space_invader:

Yeah this is very relatable. It always seems like the docs i make get scrolled through like someone who is accepting some terms of service. Things that go wrong almost always go wrong because the manual wasnt read properly

You said you were using a dialog box… Those things are ugly.

With a winform you can make it prettier. Add your company logo etc.

Oh i misunderstood. I assumed a dialog box and popup were basically the same…
Do you have an example of how those look?

They look pretty much however you want.

There should be some examples on this forum floating about. :slight_smile:

You can add whatever you want to them pretty much.

1 Like

The code they use is here:

This calls on another utility:

It’s written in C# and bundled into an exe that pyRevit calls on from what I can tell, so I assume it’s quite/too complex to handle in Python vs just managing it in C#.

I somewhat agree with John, and am exploring C# currently (literally between chapters in his Dynamo ZT course - taking a detour to refine my general C# then back to it…). We’re literally sitting on R25 at my firm right now due to the holdup from updates given it’s OS so I get his point in that regard. Whatever choices/languages we choose, we own the challenges and risks they bear.

5 Likes

An alternative with NotifyIcon class (Winform namespace)

toast with winform

import sys
import clr
import System
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
import System.Drawing
import System.Windows.Forms
from System.Windows.Forms import Application, ToolTipIcon, NotifyIcon


trayIcon = NotifyIcon()
trayIcon.Text = "Dynamo"
trayIcon.Visible = True
trayIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath)
trayIcon.ShowBalloonTip(5000, "Hello", "it's a Hello World", ToolTipIcon.Info)

OUT = 0
7 Likes