Python script issue

Hello,
I try to script my component in Python for GH. At the very beginning, I came across something odd, I provided a single Curve N1 in my script, and when trying to retrieve that Curve I got a doubled curve in the component output a. Can you please explain what the problem is, or am I doing something wrong?
Plz, see the files attached

cap1.gh (8.9 KB)

I’m not entirely certain what the code is supposed to be doing, but your issue is likely related to the y parameter access type. Try setting it to List Access instead of Item Access:

Hello Anders, thanks you for quick response, yep this is initial stage of scripting…what if I have a single curve in y slots, do I have to change access type back to “item access”? Is it possible to manipulate inside script so that we don’t have to change “access type” manually?

It really depends on your intention and preference. I usually avoid the implicit Grasshopper cycles functionality and code explicitly to whatever the input data actually (i.e. set access type to Item if the input data is just one element, set it to List if the input is a list, and set it to Tree if the input is a DataTree). Meaning that I manually type out loops and cast to/from nested Python lists. There are performance benefits to this, but for me it’s just simpler to understand and debug (i.e. because it’s explicit). But again it’s also a question of preference. Either way, have a read through this article and see what you prefer:

1 Like