Is ghdoc of GhPython component not available in cluster?

is it true for ghenv too?
I tried ghdoc.Path but when the GhPy is in cluster, ghdoc is None

What version of Rhino 6 are you using?

This should be fixed in SR1: RH-43345

Rhino version is SR 6.8

Sorry, I missed the cluster part, I am looking into this.

If you change ghdoc to self.ghdoc and ghenv to self.ghenv, it should work more robustly, because it’s clear where Python should look for what would otherwise be a global variable.

Does it help?

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

image
image

what did i miss?

When the component is initialized (at Grasshopper loading) the Grasshopper document will not be available. You should write that stuff in the component itself. self is the first parameter of each instance method in OO Python. Please also note that only RunScript will be executed at each iteration when you are in GH_Component SDK/Advanced mode.

What are you trying to do?

ghenv.Component.Something
becomes:
self.Something

also as far as I understand self.Something should be inside the class MyComponent(component):
and inside def RunScript(self):

1 Like

I took over someone else’s script and I don’t know why it’s breaking. I rewrote a quick print ghdoc.Path and put it in cluster and it works. Maybe it’s the strange interaction of os or sys modules with GH? But at this point it’s clear that the whole problem was created by unnecessary script so I’m moving on.
The script is supposed to get the file path of the currently open GH file, and import a custom library living side-by-side to the GH file. Redundant. I know.

That’s fine. It will work with the self.ghdoc code, provided that you run this in the def RunScript(self, ...) or in one of the instance methods that happen at script run time ( def BeforeSolveInstance(self) is another example).