You probably want to raise an exception: https://docs.python.org/2/tutorial/errors.html#raising-exceptions
Not that I know of. I assume you get a good message in the red balloon now?
Yes, that one is exactly what I wanted, thanks
Check out the AddRuntimeMessage()
method of the python component (ghenv.Component
), which lets you add different colours of warning balloons (note that calling it doesn’t raise an exception itself, so the script continues as usual)
Try this out:
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
ghenv.Component.AddRuntimeMessage(RML.Warning, "oops")
Note that having an actual exception raised at the same time will override the custom warning message.
You can call this method on any component on canvas which is an GH_ActiveObject
.
Oh, so my issue was I didn’t try to use it as something.AddRuntimeMessage(args)
My God this API is so difficult to use without proper python examples.
Thanks
RuntimeMessageExample.gh (3.9 KB)
thnx for showing, im really new to coding.