How can I coding runtime message in Rhino 8 's Grasshopper SDK?

I have try to convert program from Grasshopper in Rhino 7 with IronPython to Grasshopper in Rhino 8 with both IronPython and Python3 but not successful.

This error are intend after compiled it to a component

It would be great if anyone can suggest me on how to fixed it.

Here are what I have try

There are 5 different source:

  • Code A, SDK and Class(component) with ghenv.Component in class
from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import System
import Rhino
import rhinoscriptsyntax as rs

class MyComponent(component):
    
    def RunScript(self, x, y):
        a = 1
        blWarn = ghenv.Component.RuntimeMessageLevel.Warning
        ghenv.Component.AddRuntimeMessage(blWarn, "Balloon Message")
        ghenv.Component.Message = "Component Message"
        return a

  • Code B, SDK and Class(component) but use self instead of ghenv.Compoent in class
from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import System
import Rhino
import rhinoscriptsyntax as rs

class MyComponent(component):
    
    def RunScript(self, x, y):
        a = 1
        blWarn = self.RuntimeMessageLevel.Warning
        self.AddRuntimeMessage(blWarn, "Balloon Message")
        self.Message = "Component Message"
        return a
  • Code C, SDK and Class(GH_ScriptInstance) with ghenv.Compoent in class
import System
import Rhino
import Grasshopper

import rhinoscriptsyntax as rs

class MyComponent(Grasshopper.Kernel.GH_ScriptInstance):
    def RunScript(self, x, y):
        blWarn = ghenv.Component.RuntimeMessageLevel.Warning
        ghenv.Component.AddRuntimeMessage(blWarn, "Balloon Message")
        ghenv.Component.Message = "Component Message"
        a = 1
        
        return a
  • Code D, SDK and Class(GH_ScriptInstance) but use self instead of ghenv.Compoent in class
import System
import Rhino
import Grasshopper

import rhinoscriptsyntax as rs

class MyComponent(Grasshopper.Kernel.GH_ScriptInstance):
    def RunScript(self, x, y):
        blWarn = self.RuntimeMessageLevel.Warning
        self.AddRuntimeMessage(blWarn, "Balloon Message")
        self.Message = "Component Message"
        a = 1
        
        return a

  • Code E, Procedure Mode with ghenv.Compoent
blWarn = ghenv.Component.RuntimeMessageLevel.Warning
ghenv.Component.AddRuntimeMessage(blWarn, "Balloon Message")
ghenv.Component.Message = "Component Message"
a = 1

On Rhino 7

  • Complied Component with Code A will give an error
    RH7_ghenv

  • Complied Component with Code B are working properly.


On Rhino 8
Build Target is Rhino 8

  • Complied Component with Code A or Code C, will give an error
    RH8_A

  • Code B or Code D, Can’t Compile as an error

  • Complied Component with Code E are working properly. !!! this in procedure mode


Here are test overview and attached code

rh8_message.zip (80.5 KB)

Thank you very much

Hello @NongKode

I made a GH definition here that shows how these scripts can work or not work. I left notes close to each one for your information. The C# component has a bug that I will get that fixed, but this should clear up the confusion:

test_sdkMode.ghx (468.7 KB)

Let me know if you still have questions and I’d be happy to clarify more

2 Likes

Hi @eirannejad

Thank you very much for your precious time and answer :star_struck:

The problem are occur on Complied SDK Type

I have select 3 component from your example

  • CODE A : Cleaner (SDK)
  • CODE C (SDK)
  • CODE E : Cleaner

and complied as upper image, Do I miss some thing while complie it ?

then the result of them are error on SDK component but not on Script

all related files are attatched
test_sdkMode.zip (284.7 KB)





If you not mind would you please also suggest on this topic :pray:

Best Regards

Oh I see so this is with published components. Okay let me look into it. I’ll update here.

RH-81638 Published python components are missing ghenv

1 Like

Ok. I made a fix for this and will be available in next 8.7 RC build

Thanks for reporting!

2 Likes

RH-81638 is fixed in Rhino 8 Service Release 7 Release Candidate

1 Like

RH-81638 is fixed in Rhino 8 Service Release 7.