How to convert GUID to other type in Python script


1

I wanna classify the curves by the length of themselves in Python add-on component.
I thought the bunch of curves may be expressed as list, but I got stuck because of GUID type.
I can’t find the way to solve this in spite of I’m familiar with Python language. It’s my first time of dealing with grasshopper python script. Can anybody help me?

Try setting the type hint for the input to curve (RMB on the edge input for the context menu). You also want it to be list access.

2 Likes

try setting both inputs to List Access, as you provide lists in both.

I don’t know what you’re trying to do but the way the code is, you’ll get either errors or you just won’t sort the curves according to their lengths.

try this, I added also another output for lengths from 0 to 300
sort_curves_in_lists_according_to_length.gh (11.1 KB)

It works! But I don’t understand what’s the difference with your code and mine.
in line 15, for i in range(len(edges)), my code got error like the second image I uploaded.
your code doesn’t raise error despite it’s literally same with mine. Can you explain it to me?

it’s right-click on the input and choose “List Access” this allows python to treat the data in there as list.

image

1 Like