August 30

0 comments

Using ChatGPT to Create OpenSCAD Scripts for 3D Printing:

By Christopher G Mendla

August 30, 2023

3d Printing, ChatGpt

Last Updated on September 13, 2023 by Christopher G Mendla

Harness the power of ChatGPT to simplify your OpenSCAD 3D printing projects.

Using ChatGPT to write OpenSCAD code for 3d printing
Using ChatGPT to write OpenSCAD code for 3d printing

Requirements

  • A ChatGPT account (even a free one will do)
  • OpenSCAD software
  • A 3D printer and slicing software

Understanding the Basics

OpenSCAD is a unique platform where you input code to create 3D models. But what if ChatGPT could help you generate that code? This approach not only offers parameterized designs for easy tweaking but also provides a novel way to design and learn.

OpenSCAD is free to download and use.

The Issue at Hand

Imagine wanting a drain grid for your toothbrush. A 6×2 inch, 1/8-inch high grid that ensures water drips away. Simple in TinkerCad but can ChatGPT optimize this?

The Strategy

  1. Leveraging ChatGPT: Start a session in ChatGPT, either version 3.x or 4.x. You need to at least set up a free account with ChatGPT to use it. A paid account is only 20 dollars per month.
  2. Millimeters, Not Inches: Remember, the code generated will be in millimeters. Plan accordingly! If possible, it is better to specify your design in millimeters as this eliminates some confusing conversion code.
  3. Pose the Problem: Craft a precise query for ChatGPT. For instance: Write a .scad script for a drain grid measuring 80mm by 200mm by 3mm with 6 evenly spaced holes, 10mm from the block’s edge, each 3mm wide and 180mm long. The query used for this post can be found here.
  4. Analyze the Output: For our example, ChatGPT delivered a structured code. The parameterized approach facilitates modifications – say increasing the hole count. You can easily paste the ChatGPT generated code into OpenSCAD to see if you are on the right track. If not, you can edit your original ChatGPT query.

Using OpenSCAD

OpenSCAD using the code from ChatGPT
OpenSCAD using the code from ChatGPT
  1. Input the Code: Paste the ChatGPT-generated code into OpenSCAD.
  2. Visualize: Preview the design. Need more holes? Change the ‘hole_count’ parameter.
  3. Generate .stl File: Click the stl icon in OpenSCAD to create a 3D model.
  4. Note the circled icons in OpenSCAD. You can generate the model and you can export to an .stl files.

Slicing and Printing

  1. Import to your Slicer: Input the .stl file into your slicing software. I use the Creality slicing software for my printer.
  2. Tweak if Necessary: Adjust parameters if the model isn’t perfect. Generate a new .stl file if needed.
  3. Prepare for Printing: Load the revised .stl file in the slicer, transfer the gcode file to your printer, and initiate the print.
Design was too close to the edge of the platform
Design was too close to the edge of the platform
Grid made shorter by modifying parameters
Grid made shorter by modifying parameters

Outcome

While TinkerCad might be quicker for simpler designs, using ChatGPT with OpenSCAD can be beneficial for intricate projects. It’s an excellent method to understand .scad scripts and enjoy the flexibility of parameterized design.

Caveats/Tips

  • Clear descriptions are crucial. This might be more challenging than the drag-and-drop nature of platforms like TinkerCad.
  • Get things as close as possible with ChatGPT and make minor corrections with OpenSCAD.

Christopher G Mendla

About the author

A web developer living in Southampton, PA

Self motivated critical thinker and problem solver providing technology consulting services.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}