3D Printed Cube

How Can ChatGPT Be Used for 3D Printing

ChatGPT by OpenAI is an AI language model which allows conversational input to directly convert to functional code output. There are many applications, from writing poems, creating recipes, and even critically analyzing famous texts and works of art. However, the language model also has an understanding of several programming languages and syntaxes. This makes it possible to generate 3D printable models, executable code scripts, and more, using only a text prompt. While ChatGPT isn’t quite ready to create a functional model of a complex engine, it is capable of making simple shapes and also creating programs that can be used to make 3D models.

This Guide Covers

What is ChatGPT?

ChatGPT stands for Chat Generative Pre-Trained Transformer
We’ve trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, challenge incorrect premises, and reject inappropriate requests. ChatGPT is a sibling model to InstructGPT, which is trained to follow an instruction in a prompt and provide a detailed response. Source: OpenAI

With generative AI art tools like Dall-E (also made by OpenAI) becoming progressively more common, it was only a matter of time before this technology made it to the 3D world. If you’re interested in learning more, keep reading to see how you can use ChatGPT to make 3D printable models today.

ChatGPT Instructions
A prompt example from the OpenAI Best Practices document
Screenshot: OpenAI

Best Practices

ChatGPT uses a form of input called a “prompt”, which is the input from the user directed at the AI. Because the quality of the output is dependent on the input, companies like OpenAI have developed Best Practices guides to help increase the odds of success. Generally, adding additional context or information to the initial prompt will result in a more optimal answer, specifically when asking ChatGPT to create 3D models.

Prompt in ChatGPT
A failed attempt at generating a 3D model
Screenshot: OpenAI

If directly asked to make a 3D model, ChatGPT will typically respond with the above prompt, and occasionally give instructions on how to use these programs to create a model. While these steps are typically not very helpful, they do show that ChatGPT should not be taken at face value when providing responses as it can, in fact, create a 3D model. Simple primitive shapes like cylinders, cubes, and pyramids are usually fairly easy to generate, but asking for organic or complex models will usually result in the above denial.

Triangle Prompt in ChatGPT
A successful generation of a triangle and the resulting mesh in Blender
Screenshot: OpenAI
Triangle in Blender
Screenshot: Blender

Using ChatGPT to Directly Generate STL Files

3D geometry can be represented via the triangulated .STL file format, a universal standard across virtually all manufacturers and file repositories. This is also a human-readable file format if generated as ASCII .STL, which makes debugging and interpreting the output of ChatGPT a little easier.

The Geometry of a cube in ChatGPT
The geometry of a cube in ChatGPT
Screenshot: OpenAI
Failed Cube
An unsuccessful result
Screenshot: Blender
Cube in Blender
The resulting mesh
Screenshot: Blender

To successfully generate an .STL file, it usually takes a few attempts that each add progressively more information to the mesh. From the above triangle example, I asked ChatGPT to use this same format to generate a cube.

It then generated six faces, which is six triangles short of a fully triangulated cube. ChatGPT will abruptly stop after a certain point when generating a large file, but adding “Continue” as a prompt will allow it to continue from where it stopped. Using the free 3D modeling program Blender, I added in the missing geometry and fixed the flipped faces (shown in red above).

Javascript script in ChatGPT
Using ChatGPT to create a Javascript script
Screenshot: OpenAI
Cube in Three.js
Screenshot: Three.js

Using ChatGPT to Generate Scripts for 3D Modeling

Another key feature of ChatGPT is the ability to create scripts to parametrically create 3D models. Using Javascript and the three.js library, I was able to quickly generate a script that creates a cube in a 3D environment by using the prompt: “Please create a script using Javascript that generates a cube and uses a GUI to display it.”. This script also generated a GUI that allows for rotational control over X, Y, and Z axes.

Sphere in Treejs
Adding an “Export .STL” function allows users to download a 3D printable file
Screenshot: Three.js
Low Poly Sphere in Blender
Sphere Result in Blender

By incrementally increasing the requested complexity, the script can create gradually more complex outputs. For example, here the cube has been replaced with a sphere, and a slider has been added that controls the number of segments on the sphere, giving it a progressively more Low Poly / decimated appearance.

By also adding an “.STL Export” function, the final geometry can be exported in the ASCII .STL file format for 3D printing. The full code can be found on GitHub, and there is also a live build available if you want to try it yourself.

3D Printed Cube
A 3D printed cube generated by ChatGPT
©3DWithUs – Print & Photo: Andrew Sink

Featured cube model 3D printed in tri-color PLA on Elegoo Neptune 3 Pro.

Printing Models Made with ChatGPT

Programs like Blender can be used to clean and prepare these mesh files for 3D printing, as seen in the video I made covering this topic. Issues like missing triangles, flipped normals, and other mesh-related problems are common, so some manual clean-up will likely be required if the intent is to 3D print any models generated with ChatGPT. Models like the 3D printed cube are generated using arbitrary units with each side measuring one unit long, which corresponds to a single mm when imported into a slicer like PrusaSlicer.

ChatGPT Welcome page
Image: OpenAI

How to Access

ChatGPT is currently available for public use and accessible directly through the OpenAI site. Use of the ChatGPT system requires an OpenAI account, which you can create using your email address. Creating an account allows users to access their full prompt history, which is a helpful way to reflect on which prompt strategies work and which don’t. While access can be limited and the service tends to have periods of interruptions, it’s still an exciting tool with a great deal of potential.

Read More: How to Use AI Art Generator for 3D Print Design

In this article, I’ll cover how to get started with AI art and text-to-image generators from the perspective of gathering references for 3D Printable products.

FLSUN S1 Livestream Event

Leave a comment

We encourage and welcome topic related comments. Comments with links will be held briefly for moderation. Links to social media profiles can be inserted into the Website tab. Your email address will not be published. To have an image/avatar, users must be registered at Gravatar. Happy Commenting!