Last weekend, I worked on advancing my Processing code skills and get a proof-of-concept prototype running. The sketch enables the user to click and draw lines on the canvas. Right-clicking a line will delete it. As a pilot for implementing some “random” elements and generative design to the application, I created the “Grow Limbs” button. This picks a random point along a random line, and then draws a new line from it within the canvas. When the user is satisfied with their drawing, they can click the “Compile GCode” button to print out NC code that will draw what is shown on the canvas in a 4″ x 4″ box using a CNC machine outfitted with a pen. Unfortunately, the web version will not show this code
Here it is below:
NOTE: Java Applets are on their way out of the interwebs… this may not work in your browser. Sorry!
When running the application on my computer, clicking the “Compile Gcode” button gives me some output in the black Console window:
Here is the G-Code output from the sketch above:
G20 G1 Y4.0 F50 X4.0 Y0.0 X0.0 G1 Z0.15 X2.7 Y0.22 Z0.0 X0.72 Y3.26 Z0.15 X2.441 Y0.618 Z0.0 X0.882 Y2.869 Z0.15 X1.679 Y1.717 Z0.0 X1.415 Y3.716 Z0.15 X1.546 Y2.729 Z0.0 X0.365 Y3.322 Z0.15 X1.784 Y1.566 Z0.0 X3.624 Y1.205 Z0.15 X1.902 Y1.445 Z0.0 X0.742 Y2.276 Z0.15 X1.03 Y2.069 Z0.0 X0.532 Y1.981 Z0.15 X1.134 Y1.995 Z0.0 X2.193 Y2.657 Z0.15 X3.139 Y1.301 Z0.0 X3.629 Y0.625 Z0.15 X1.652 Y1.927 Z0.0 X1.718 Y2.87 Z0.15 X1.638 Y2.028 Z0.0 X0.151 Y2.489 Z0.15 X1.456 Y3.408 Z0.0 X2.367 Y1.911 Z0.15 X1.747 Y1.556 Z0.0 X0.703 Y1.26 Z0.15 X0.0 Y0.0
The next step is to check the code in OpenSCAM to make sure that it looks right:
And finally, I can send the .NC file to my Shapeoko for it do draw:
The next steps for development will be to create an actual product that I can customize using the process above. Some of the classes, and methods I’ve written will be able to transfer to the new program. I also want to implement a bit more in the way of generative design. With each iteration, I hope to add a bit more functionality, and take the process a bit further.