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.
print circles
For example will show the contents of âcirclesâ
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
Yup yup that is what is I did, the points are appended to b. But the output from b, if connected to a panel actually reads: âIronPython.Runtime.Listâ.
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.