Object Reference not set to an instance of an object for Python Component

Hi, I am trying to develop a simple land use allocation script using python for an urban development project and I am getting the above error when I am trying to take the output of the script and allocate it to curves. The error comes up when I am trying to change the iteration. I am new to scripting so any help would be appreciated!

I have also found a similar topic in the forum about this error "object reference not set to an instance of an object" - #5 by hieunguyen), so I am aware that this might be a problem with curve guids, although I don’t quite understand how to apply the solution in my script.

Thank you in advance.

Land Use Allocation.gh (72.7 KB)

I just tried you script and played around with the iterations slider and for me it works fine! What version of Rhino are you running?

1 Like

Thank you for your response!

I have tried it in rhino 6 and rhino 7.

For some weird reason sometimes works fine but after a while, it shows up the above error.

That’s indeed weird.

1 Like

Could you please open and edit another grasshopper file while you have this open and then come back and try to change the iteration again? Sometimes it gives me the error after I do that.

I previously had two other documents open, but I’m on macOS, so maybe that’s a factor?

1 Like

To be honest, I have tried it on macOS as well!

Anyway, thank you for your response!:slight_smile:

I am not sure how this all precisely works, but to me it seems that the error happens because somehow your data gets stale (for lack of better understanding and wording). Once you get the error you can get back to working again by forcing the first python component in the definition to execute.

To ensure it gets always executed you could add a dummy input to it and connect your iterations slider to it. That will ensure your first python component (and everything after it) gets executed always ensuring good data in your lists.

Not sure who knows most about the Python component, maybe @piac or @DavidRutten ?

1 Like

I had this problem when the output is guid.

Thank you for your response, that was very helpful!

It works perfectly for now!

1 Like

Check this if solve the problem, you need to change Type Hint of x and y to Curve

2 Likes

Thank you for your response!

That works as well and it might be a better solution!