How to Use ChatGPT for 3D Printing: From Prompt to G-Code or STL File
Unlock the Potential of ChatGPT in 3D Printing
ChatGPT has become a sensation online since its emergence a few months ago. In addition to helping generate answers to simple queries, the chatbot can prepare files for 3D printing. With ChatGPT, you can create ready-to-print STL files, code for 3D models that can be opened using scripting-based 3D modeling software such as OpensCAD or create Gcode files without a 3D slicer.
Below, we’ll explore each of these strategies in detail. Remember that ChatGPT is only as good as the prompts you give it and you may have to try several different wordings to get what you want.
How to Generate G-Code Using ChatGPT
We shall generate the G-code in ChatGPT, preview it, and then send it to a 3D printer. If you have not tried the chatbot, you can access it at by registering and logging into Openai. You should see the option to enter your prompts when you log in.
You can think of any design and ask the software to generate the printable file. In my case, I want to create a simple 3D model of a cube. If I ask the chatbot to develop a 3D model I can print, it will display a general response, as shown below.
To get a 3D-printable file, we must ask the software to generate ASCII STL. ASCII STL format stores human-readable details of the triangular facets that make the object surface. Each vertex is connected to other vertices in the model, creating triangles that define the shape of the 3D model.
Below is a section on the ASCII STL format for designing a cup.
The file always starts with Solid <name>, where name is the name of your design. Next, you will see the details of the triangle’s vertices, and the code ends with the name endsolid <name>.
Stay On the Cutting Edge: Get the Tom's Hardware Newsletter
Get Tom's Hardware's best news and in-depth reviews, straight to your inbox.
You can follow the steps below to create the 3D model in ChatGPT.
1. Write the prompt “Generate a 3D Model of a cube using ASCII STL format,” then click enter. Below is a sample of the code generated.
You can download the complete file on Google Drive.
2. Copy the code and paste it to any text editor like Notepad, and then you can save it.STL. If you understand how the code works, you can modify it.
3. Import the file to Cura or any other 3D slicing software to slice it and generate the G-code we shall send to the 3D printer. It’s also helpful in previewing it and checking how it will be 3D printed. I also realized the design generated by ChatGPT the first time was very tiny, and I had to scale it on Cura, as shown below.
4. Send the file to your 3D printer. After slicing, you can preview by moving the sliders on the right and bottom of the interface to see if everything is in order. You can also specify speed, layer height, temperature, and other settings depending on your 3D printer.
Next, you can send the file to your machine for 3D printing. The design took around 6 hours to 3D print, and I was impressed with the outcome as it had no flaws.
If you can see well, the surfaces and edges were 3D printed perfectly, and the surfaces were smoother.
In addition to using ChatGPT to generate STL files, you can also fix the G-code files you can send to your 3D printer directly without using a 3D slicer.
How to Fix G-code Files in ChatGPT
To demonstrate this, I downloaded a 3D model of a Minecraft Creeper from Thingiverse and sliced it using Cura to get the G-code. I then opened it on Notepad and modified the sections highlighted below, adding letters instead of numeric values from line 5.
I then saved the file, and when I tried opening it in Cura, I got the error below.
Instead of taking a lot of time to identify the errors, ChatGPT can detect them easily. So I copied the file, pasted it into ChatGPT, and asked the bot to identify the mistakes. This was the response I received.
As you can see, it was able to detect that the values on lines 5, 7, and 10 are not numeric because I added letters.
You can also go ahead and tell it to fix it. In this example, I used the prompt, “Please fix the errors you identified.” As you see, it replaced the letters with random numbers.
In addition to fixing the G-code and generating STL files in ChatGPT, you can also use it to generate scripts of 3D models that you can use in 3D modeling software like OpensCAD. Follow along as we show you.
How to Generate Scripts of 3D Models in ChatGPT
If we want a 3D model we can manipulate, we can just ask for one. Here, we’ll tell it to generate a script of a 3D model of a cup that we can use in OpensCAD. I used the prompt “Create a Script of a 3D model of a cup to be opened in OpensCAD.”
Below is the output that I got.
After generating the code, I downloaded OpensCAD, created a new file, and pasted the code into the editor. After saving and rendering the model, I got the design shown below.
It almost resembled a cup though it’s a little off. But you can play around with the prompts and the code until you achieve the perfect design of a cup. You can save the file as an STL file by selecting the STL option on the top-left section of the toolbar.
You can then send it to your 3D slicer and slice it. After slicing, the time taken to print the model is estimated to be 57 minutes.
After 3D printing, I was able to get the design shown below.
As you can see, it has a smooth surface and is generally good, just like the other one for the cube. You can always experiment with various prompts, and you will be able to create an incredible design.
-
neoculture All I keep getting are variations on "I'm afraid I can't do that, Dave". Generally of the "...as a text-based AI model, I cannot directly generate or provide 3D models..." variety.Reply -
mscir I asked openai's chat gpt if it could generate the g-code or stl for a roughly 1 foot long t-rex skull. It said yes. I asked it to do so, it generated a few dozen lines of code before the chat window stopped showing it. I told it the file was too large for the chat window, it apologized, I asked if it could generate the file and make it available for download, it said yes, I asked it to do so and send me the download link, it sent me a link to a gmail account that didn't exist. I was already logged into my gmail account in another tab on the same browser, so I asked it how we could proceed, it apologized and said it was not possible to create the file since it might be a copyright violation of some sort, and it said it didn't have access to an account where I could download the file even if it was able to post one. So it wasted a lot of time being quite stupid.Reply -
Pi-Plates chatGPT seems to have very limited capabilities of creating anything other than cubes. Case in point: "Generate a 3D Model of a skeleton using ASCII STL format" produced an STL file of a 4 sided cube with the disclaimer "This is a very basic and abstract representation of a skeleton using ASCII STL format. It defines a simple cube, which can be interpreted as a basic representation of a skeleton's structure. A more detailed and recognizable representation of a skeleton would require complex 3D modeling software."Reply