Ghenv is not usable after compiling ghpython. How to add warning in ghpython after compile?

ghpython
compiler
unhandled

#1

Hello All!
:grinning:

ghenv.Component.AddRuntimeMessage(gh.Kernel.GH_RuntimeMessageLevel.Error, ErrorStr)

This works OK before compile in ghpython, but wrong after compile: global name “ghenv” is not defined.
How to add warning or error in ghpython after compile?


(Chris Hanley) #2

I don’t remember the specifics, (and I’m away from my work computer), but I ran into a similar issue when writing the components here:

Maybe take a look at the differences in the ghdoc declaration? I’m a little fuzzy, but I definately remember having to fix a similar issue between the procedural code version and the python compiled, (sdk) version.


#3

Thank you chanley, I’ll take a look on that to see if I can find some solution.


#4

I learn a lot from your python code.

I should change

ghenv.Component.AddRuntimeMessage(gh.Kernel.GH_RuntimeMessageLevel.Error, ErrorStr)

into:

self.AddRuntimeMessage(gh.Kernel.GH_RuntimeMessageLevel.Error, ErrorStr)