Class instance between two gh python components

Hi everyone,

I met an issue with transferring class instances from one ghpython component to the connecting one: I created a class in the first component, and pass one instance to the connecting component to let it do the next steps. But when I hit Test on the 2nd component, It doesn’t work and says “Object reference not set to an instance of an object.”
I assume that means the class instance hasn’t been correctly sent to the 2nd component, so I get back to the 1st one to check. I didn’t find anything incorrect, so I click OK to close the ghpython editor. At this moment the 2nd one started to work.
My speculation is the 2nd component requires the 1st component to rerun to pass the class instance correctly. But I don’t know why and what happened in this process. To me, it seems counterintuitive and doesn’t make much sense. Since the class instance should be passed at the first run.
My temp solution is adding a button do nothing but reactivate the first component as shown in the 2nd image. It works but I am still curious why this thing happens and how can I prevent this.

Thank you!

ghpython_connecting_example.gh (46.0 KB)

I’m on my phone so can’t check the file, but try this solution (i.e. use RhinoCommon directly):

Also note the specific behaviour of hitting the Test button, which might also explain your issue:

Thank you! Yes, Rhino Common works. It’s a bit confusing why does rhinoscriptsyntax not work though…

1 Like