I am having quite some trouble translating this into python:
Thanks to help in this forum I was able to create my own series of radii. I created the circles, but now I need to divide each one. The problem is that for loops do not take Guids as iterable objects…
‘a’ is your list of circles.
‘Circles’ is a variable inside your for loop and only one circle at a time. And after the for loop ends holds the circle corresponding to your maximal I.
You try to iterate over the one GUID objet that is stored as ‘circles’.
Rather try iterating over a which is your list of circles. Ä
You can also use print statements to find obvious mistakes in your code.
Zoom in on the ghpython component and on the outputs click the ‘+’ icon. A new output called ‘b’ will be cteatesent. Append your points to a list b and you can visualize and use them
Ah sorry you can either activate the preview of the ghpython component, or if you want to do more things with the points down the line plug them into a ‘pt’ component. If that doesn’t work maybe upload your current definition and I’ll take look.
I think you are running into a “list of lists” issue. There are 2 options that you could do, (as your code exists).
1 : use an additional python component by simply setting a = x
2: use an additional import statement to access a “list to data tree” function (Rhino 6 only)
import rhinoscriptsyntax as rs
import ghpythonlib as gh
start = S
step = N
count = C
radii = [start + (i * step) for i in range(int(count))]
a = []
for i in radii:
circles = rs.AddCircle([0, 0, 0], i)
a.append(circles)
b = []
segs = E
for i in a:
pts = rs.DivideCurve(i, segs)
b.append(pts)
a = gh.treehelpers.list_to_tree(a, True, [0])
b = gh.treehelpers.list_to_tree(b, True, [0])
The screen shot you show, (I believe), was before the function was available in “import ghpythonlib”. As of Rhino 6, you can just call the function direclty, (after importing ghpythonlib).
I think that the treehelper functions are pretty handy and straightforward when dealing with data trees. In the rhino 6 code I posted above, I only added 3 lines to what you had originally. I don’t think that’s an unreasonable amount of complexity.
Indeed, but I have not upgraded to Rhino 6 yet, and I am thinking of all the time before Rhino 6 when someone wanted to do this and had to create the function manually, even more for an unexperienced user in Python like myself.