Discovering GPT’s 3D Modeling Potential: An Intriguing Experiment

Charting New Territories in AI-Assisted Design and Collaboration

Gil Meiri
𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨
7 min readMay 3, 2023

--

Introduction

In recent times, the application of artificial intelligence in various fields has skyrocketed. One such field is 3D modeling, where AI has the potential to revolutionize the way we design and create objects. In this blog post, I will share my personal experience of using GPT, an AI language model, in conjunction with my own input to create a 3D model using FreeCAD, an open-source 3D modeling software. I will walk you through the conversation I had with GPT and the iterative process that led to a successful 3D model, including the code used. For my experiments I used GPT-4.

Starting the journey: Finding the right tool

My journey began when I asked GPT to generate G-code for a 1 cm x 1 cm x 1 cm test cube for an Ender 3 3D printer. G-code is a programming language that instructs 3D printers on how to create objects layer by layer. However, GPT wasn’t able to generate the desired G-code directly, which led us to explore other options.

After discussing the limitations of G-code, I asked GPT if it could create an STL file directly. It responded that it couldn’t create STL files but suggested it could provide instructions on how to create a model in popular 3D design programs like Tinkercad, Fusion 360, or Blender. While these programs are powerful and widely-used, I was looking for a more automated process where GPT would be doing most of the work, rather than merely providing instructions.

Acknowledging the need for a more accessible scripting interface that would allow GPT to play a larger role in the process, I then asked GPT if it could create code for FreeCAD. GPT was able to do so, and we decided to use FreeCAD for our project. What truly astonished me was that GPT not only supplied the code but also offered comprehensive guidance on inputting the Python script into FreeCAD, even though I hadn’t specifically requested such assistance. This made the process considerably more effortless, especially since I had never used FreeCAD before.

Starting small: The Cube

With FreeCAD as our tool of choice, we began by creating a simple 1 cm x 1 cm x 1 cm cube. GPT provided the following code to create the cube using Python scripting in FreeCAD:

import FreeCAD
import Part

doc = FreeCAD.newDocument()

# Cube dimensions
cube_length = 10
cube_width = 10
cube_height = 10

# Create cube
cube = doc.addObject("Part::Box", "Cube")
cube.Length = cube_length
cube.Width = cube_width
cube.Height = cube_height

doc.recompute()

This initial success proved that AI could help in creating 3D models, and I decided to take it a step further by attempting to create a more complex object.

Taking flight: The Airplane Model

Our next challenge was to create a basic airplane model. When asked to do so, GPT came up with the following code:

import FreeCAD
import Part

doc = FreeCAD.newDocument()

# Fuselage dimensions
fuselage_length = 100
fuselage_radius = 10

# Wing dimensions
wing_length = 80
wing_width = 5
wing_thickness = 2

# Tail dimensions
tail_length = 30
tail_width = 3
tail_thickness = 2

# Create fuselage
fuselage = doc.addObject("Part::Cylinder", "Fuselage")
fuselage.Radius = fuselage_radius
fuselage.Height = fuselage_length
fuselage.Placement.Base = FreeCAD.Vector(0, 0, 0)

# Create wing
wing = doc.addObject("Part::Box", "Wing")
wing.Length = wing_length
wing.Width = wing_width
wing.Height = wing_thickness
wing.Placement.Base = FreeCAD.Vector(fuselage_length / 2 - wing_length / 2, -wing_width / 2, fuselage_radius)

# Create tail
tail = doc.addObject("Part::Box", "Tail")
tail.Length = tail_length
tail.Width = tail_width
tail.Height = tail_thickness
tail.Placement.Base = FreeCAD.Vector(fuselage_length - tail_length / 2, -tail_width / 2, fuselage_radius)

doc.recompute()

This first iteration genterated the following disappointing result.

I informed GPT that the program didn’t resemble a plane at all and requested that it make another attempt. The code for the second attempt was as follows:

import FreeCAD
import Part

doc = FreeCAD.newDocument()

# Fuselage dimensions
fuselage_length = 100
fuselage_radius = 5

# Wing dimensions
wing_length = 60
wing_width = 100
wing_thickness = 2

# Tail dimensions
tail_length = 30
tail_width = 40
tail_thickness = 2

# Create fuselage
fuselage = doc.addObject("Part::Cylinder", "Fuselage")
fuselage.Radius = fuselage_radius
fuselage.Height = fuselage_length
fuselage.Placement.Base = FreeCAD.Vector(0, 0, 0)

# Create wing
wing = doc.addObject("Part::Box", "Wing")
wing.Length = wing_length
wing.Width = wing_width
wing.Height = wing_thickness
wing.Placement.Base = FreeCAD.Vector(fuselage_length / 2 - wing_length / 2, -wing_width / 2, fuselage_radius)

# Create tail
tail = doc.addObject("Part::Box", "Tail")
tail.Length = tail_length
tail.Width = tail_width
tail.Height = tail_thickness
tail.Placement.Base = FreeCAD.Vector(fuselage_length - tail_length, -tail_width / 2, fuselage_radius + fuselage_radius / 2)

# Create vertical stabilizer
vertical_stabilizer = doc.addObject("Part::Box", "VerticalStabilizer")
vertical_stabilizer.Length = tail_thickness
vertical_stabilizer.Width = tail_width / 3
vertical_stabilizer.Height = fuselage_radius * 2
vertical_stabilizer.Placement.Base = FreeCAD.Vector(fuselage_length - tail_length / 2, -tail_thickness / 2, fuselage_radius * 2)

doc.recompute()

The second attempt was an improvement over the first, but there were still significant issues to address. For example, the fuselage and stabilizer orientations were incorrect, and the wing dimensions seemed too large. I began providing GPT with iterative feedback to help refine the code. I shared comments like, “The fuselage isn’t oriented correctly. Please fix the code,” and “The stabilizer is still oriented wrong. It is oriented towards the y-axis, and it is at the very start of the tail.”

This back-and-forth dialogue with GPT allowed us to identify and address problems, leading to multiple iterations that resolved the stabilizer’s orientation and fine-tuned other aspects of the model, such as adjusting the wing and tail lengths to prevent overlap.

Through continuous iterations, we successfully refined the airplane model, correctly positioning the wings, tail, and vertical stabilizer. Here’s the final code for the airplane model:

import FreeCAD
import Part

doc = FreeCAD.newDocument()

# Fuselage dimensions
fuselage_length = 100
fuselage_radius = 5

# Wing dimensions
wing_length = 40
wing_width = 100
wing_thickness = 2

# Tail dimensions
tail_length = 20
tail_width = 40
tail_thickness = 2

# Vertical stabilizer dimensions
vertical_stabilizer_width = tail_width / 3
vertical_stabilizer_height = fuselage_radius * 2

# Create fuselage
fuselage = doc.addObject("Part::Cylinder", "Fuselage")
fuselage.Radius = fuselage_radius
fuselage.Height = fuselage_length
fuselage.Placement.Rotation = FreeCAD.Rotation(FreeCAD.Vector(0, 1, 0), 90)
fuselage.Placement.Base = FreeCAD.Vector(0, 0, fuselage_radius)

# Create wing
wing = doc.addObject("Part::Box", "Wing")
wing.Length = wing_length
wing.Width = wing_width
wing.Height = wing_thickness
wing.Placement.Base = FreeCAD.Vector(fuselage_length / 2 - wing_length / 2, -wing_width / 2, fuselage_radius)

# Create tail
tail = doc.addObject("Part::Box", "Tail")
tail.Length = tail_length
tail.Width = tail_width
tail.Height = tail_thickness
tail.Placement.Base = FreeCAD.Vector(fuselage_length - tail_length, -tail_width / 2, fuselage_radius + fuselage_radius / 2)

# Create vertical stabilizer
vertical_stabilizer = doc.addObject("Part::Box", "VerticalStabilizer")
vertical_stabilizer.Length = vertical_stabilizer_height
vertical_stabilizer.Width = tail_thickness
vertical_stabilizer.Height = vertical_stabilizer_width
vertical_stabilizer.Placement.Base = FreeCAD.Vector(fuselage_length - vertical_stabilizer_height, -tail_thickness / 2, fuselage_radius + fuselage_radius / 2)

doc.recompute()

The experiment would be incomplete without actually printing the model.

The final model, though still relatively simple, represented a considerable enhancement compared to the initial design, highlighting the promising potential of employing AI in 3D modeling, albeit with human guidance at this stage. I found the end result to be a satisfactory proof of concept, showcasing the capabilities of AI-assisted 3D modeling.

More details

The final model took 10 iterations to create.

You can see the full transcript of our conversation here (including the part used to write this blog). Be sure to read the comments, as they provide valuable context and showcase the outcomes of the code snippets.

Conclusion

In conclusion, our experience with GPT in creating a 3D model highlights the immense potential of AI in the world of design and manufacturing. As a proof of concept, this collaboration between human guidance and AI assistance proved to be quite effective. Just imagine the possibilities if AI were able to automatically plug into software like FreeCAD, analysing the images and auto-correcting itself, streamlining the design process even further.

If AI could integrate more seamlessly with powerful design tools, including industry-standard software like Fusion 360 or SolidWorks, it could revolutionize the way we approach design and manufacturing. AI’s ability to make “design for manufacture” more cost-effective would have far-reaching implications, not only reducing production expenses but also positively impacting the economy as a whole.

The capacity of AI to analyze designs and suggest improvements or alternatives could speed up the product development cycle, making innovation more attainable for individuals and companies alike. This could have a significant impact on various industries, from automotive and aerospace to consumer goods and medical devices.

As AI technology advances and its integration with design software becomes more sophisticated, we can expect a paradigm shift in how we approach design, manufacturing, and innovation. The synergy between human creativity and AI’s analytical capabilities has the potential to usher in a new era of progress, transforming our world for the better.

FYI: *Most* of this post was written by GPT.

--

--