Python Resources

Updated on Aug 4 2024

Python Resources

Deborah R. Fowler



File creation to supplement Exercise 2 dailies - creating the circle data

Posted on April 23 2022

The node I used for the circle and maple leaf generation was the trace node. Given an image this will return geometry. Here is the circle example, the maple leaf is similar but introduces a little bit of vex code.

Overall, the node network looks as follows:





A resample node was used to reduce the number of points on the outline curve and evenly space those points.



An add node was used to delete everything except the points.



Since my goal was to create a file suitable for turtle I used a transform node to scale the circle up by 300.
I am also previewing what it would like like by adding an add node with * in the polygon tab to join the points.



The last node before we write it out is to add the first point to the end so that the outline is closed. Here I used an add node and referenced the first point coming in from the node above.
In hscript we can use the point function which requires 4 arguments, a path to the node being referenced, the point number used, the attribute (in this case "P") and the element (x,y,z corresponds to 0,1,2)
So for example the x position of the first point is point("../transformForTurtle",0,"P",0)



Another way to do this is with a pointwrangle (vex instead of hscript). The point function in vex is different. It returns a vector so the point arguments (geometry, string, pointnumber) are point(0,"P",0) and we then use the addpoint function.



Now we are ready to write out the data using python.