Get all your news in one place.
100’s of premium titles.
One app.
Start reading
Tom’s Hardware
Tom’s Hardware
Technology
Sammy Ekaran

How to Use ChatGPT for 3D Printing: From Prompt to G-Code or STL File

Use ChatGPT for 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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

The file always starts with Solid , 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 .

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

If you can see well, the surfaces and edges were 3D printed perfectly, and the surfaces were smoother.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

I then saved the file, and when I tried opening it in Cura, I got the error below.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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.

(Image credit: Tom's Hardware)

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. 

(Image credit: Tom's Hardware)

After 3D printing, I was able to get the design shown below.

(Image credit: Tom's Hardware)

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.

Sign up to read this article
Read news from 100’s of titles, curated specifically for you.
Already a member? Sign in here
Related Stories
Top stories on inkl right now
One subscription that gives you access to news from hundreds of sites
Already a member? Sign in here
Our Picks
Fourteen days free
Download the app
One app. One membership.
100+ trusted global sources.