I wanted to see if generative AI such as ChatGPT and Google Gemini could be used to create a file (.STL) that could be sent to a 3D printer and turned into a tangible object. The short answer is yes. It’s doable, especially if you don’t care about things like tolerances. But I wanted to see if I could print an enclosure for an Arduino, which would require exact dimensions.
BLUF: It created an 80% solution. The overall size and fit were spot on. The Arduino was snug but fit. The cutout for the USB port was spot on, but the cutout for the DC barrel jack was off. I could not use the file generated as-is; it would take some modifications. But seeing as this is still the early days of generative AI, I wouldn’t be surprised to see this perfected in a year or so.
Python Script
ChatGPT created a Python script that I ran on my local machine to generate the STL file that I then sent to my printer. The nice thing is that it created a well-documented parametric solution, so it is relatively trivial to change some numbers to adjust the tolerances of the final 3D model. After many tries, it eventually settled on a solution that required the Numpy and Trimesh libraries.
It initially tried to create a solution requiring OpenSCAD, which I didn’t want to utilize. My initial prompt was as follows:
Create a Python script that can generate the STL file needed to 3D print a functional enclosure for an Arduino Uno Rev 4.
It created a Python script that rendered a generic box.
So, instead of rewriting my initial script, I simply conversed with ChatGPT. Subsequent prompts were as such:
please add cutouts for the usb port, dc power jack, and header pins
the cutouts for the dc power jack and usb port are in the wrong place. they should be on the side of the base model
In the end, I was given a Python script I saved as a .py file, and from my computer command prompt, Iran the following command:
>python ./arduinoenclosuregen.py
That, in turn, generated two .STL files, one for the bottom of the enclosure and one for the lid. Those were sent to the printer. To grab the code yourself, visit https://github.com/mbparks/PythonArduinoEnclosureSTL
Here are some pics of the process.