String Art in Rhino Python
String art is a captivating technique that combines geometry and aesthetics to recreate images using lines between pins. Here is a good reference to start studying it. In this post, we explore a custom Python script designed for Rhino. It transforms a grayscale image into a dense web of threads. The algorithm analyzes the darkest areas of the image and connects pins in a circular layout to form compositions. The script begins by converting a user-selected image into grayscale and masking it within a circular region. The user defines the number of pins and lines. From there, the algorithm evaluates possible connections. Then, it selects the one with the lowest average brightness at each step. Each line subtly lightens the image along its path, progressively refining the output. The code displays the final result in the Rhino viewport as a polyline, with numbered pins for reference.

I developed this code in Rhino 8 (Python 3), but it also works well in Rhino 7 (IronPython, a bit slow). To run the code, simply open the Python editor in Rhino, paste the script, and run it. Then, you will be prompted to select an image file and enter parameters like contrast, number of lines, and number of pins. After processing, the string art pattern will appear in the Rhino viewport with numbered pins for reference. Note that you may wait for a long time if you enter large numbers. Also, the physical output will depend on the thickness and the transparency of the string you choose.
If you like this content, would you consider being my Patreon if you want to support this website by downloading my working Grasshopper file? Here is the link to my Patreon page, including the String Art code and more. Thank you.

