Blender and AI- Modeling a car

Since several hours I try to tell Chatgpt to make a script for blender contructing a simple car. It writes vvery promising script but when I put these in Blender text editor and say “run” the rtesults are disappointing. Has somebody better experiences an can guide me a little bit?
Heres an example for these scripts. Its a pity that one cannot copy the error messages of blender to insert them into CharGpt (or is therae a way?)

import bpy
import math
from mathutils import Vector, Euler

---------- Scene reset (robust) ----------

def reset_scene():
bpy.ops.wm.read_factory_settings(use_empty=True)
# Ensure new empty scene
if bpy.context.scene is None:
bpy.data.scenes.new(“Scene”)
bpy.context.window.scene = bpy.data.scenes[“Scene”]

---------- Material helper ----------

def make_principled_material(name, base_color=(0.14, 0.25, 0.8, 1.0), metallic=0.6, roughness=0.25):
mat = bpy.data.materials.get(name)
if not mat:
mat = bpy.data.materials.new(name)
mat.use_nodes = True
nt = mat.node_tree
bsdf = nt.nodes.get(‘Principled BSDF’)
if not bsdf:
bsdf = nt.nodes.new(‘ShaderNodeBsdfPrincipled’)
# link to material output
out = nt.nodes.get(‘Material Output’) or nt.nodes.new(‘ShaderNodeOutputMaterial’)
nt.links.new(bsdf.outputs[‘BSDF’], out.inputs[‘Surface’])
bsdf.inputs[‘Base Color’].default_value = base_color
bsdf.inputs[‘Metallic’].default_value = metallic
bsdf.inputs[‘Roughness’].default_value = roughness
return mat

---------- Build: car body ----------

def create_car_body():
# Main body
bpy.ops.mesh.primitive_cube_add(size=2.0, location=(0, 0, 0.5))
body = bpy.context.active_object
body.name = “CarBody”
body.scale.x = 1.6
body.scale.y = 0.8
body.scale.z = 0.35
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

# Cabin
bpy.ops.mesh.primitive_cube_add(size=1.2, location=(0.1, 0.0, 1.0))
cabin = bpy.context.active_object
cabin.name = "Cabin"
cabin.scale.x = 0.9
cabin.scale.y = 0.7
cabin.scale.z = 0.45
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

# Join (OBJECT mode safe)
body.select_set(True)
cabin.select_set(True)
bpy.context.view_layer.objects.active = body
bpy.ops.object.join()

# Material
car_mat = make_principled_material("CarPaint", base_color=(0.14, 0.25, 0.8, 1.0), metallic=0.6, roughness=0.25)
body.data.materials.clear()
body.data.materials.append(car_mat)

# Origin to bounds bottom center
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
return body

---------- Build: wheels ----------

def create_wheel(name=“Wheel”, radius=0.26, width=0.2, location=(0,0,0.25)):
bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=radius, depth=width, location=location)
wheel = bpy.context.active_object
wheel.name = name
wheel.rotation_euler = Euler((math.radians(90), 0, 0), ‘XYZ’)
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)

tire_mat = make_principled_material("TireRubber", base_color=(0.05, 0.05, 0.05, 1.0), metallic=0.0, roughness=0.85)
wheel.data.materials.clear()
wheel.data.materials.append(tire_mat)
return wheel

def add_wheels(body):
x_off = 1.2
y_off = 0.75
z = 0.26
positions = [
( x_off, y_off, z), # FR
( x_off, -y_off, z), # FL
(-x_off, y_off, z), # RR
(-x_off, -y_off, z), # RL
]
names = [“Wheel_FR”, “Wheel_FL”, “Wheel_RR”, “Wheel_RL”]
wheels =
for pos, nm in zip(positions, names):
w = create_wheel(name=nm, radius=0.26, width=0.22, location=pos)
w.parent = body
wheels.append(w)
return wheels

---------- Environment: ground, camera, sun ----------

def setup_env():
# Ground
bpy.ops.mesh.primitive_plane_add(size=30, location=(0, 0, 0))
ground = bpy.context.active_object
ground.name = “Ground”
ground_mat = make_principled_material(“Ground”, base_color=(0.9, 0.9, 0.9, 1.0), metallic=0.0, roughness=0.7)
ground.data.materials.clear()
ground.data.materials.append(ground_mat)

# Camera (data API)
cam_data = bpy.data.cameras.new("CarCam")
cam = bpy.data.objects.new("CarCam", cam_data)
bpy.context.collection.objects.link(cam)
cam.location = Vector((4.5, -5.2, 2.2))
cam.rotation_euler = Euler((math.radians(70), 0, math.radians(35)), 'XYZ')
bpy.context.scene.camera = cam

# Sun (data API; angle instead of radius)
sun_data = bpy.data.lights.new(name="Sun", type='SUN')
sun_data.energy = 3.0
sun_data.angle = math.radians(2.0)  # softness
sun = bpy.data.objects.new("Sun", sun_data)
bpy.context.collection.objects.link(sun)
sun.location = Vector((5, -5, 8))

# Render engine: be resilient across versions
try:
    bpy.context.scene.render.engine = 'BLENDER_EEVEE_NEXT'
except:
    bpy.context.scene.render.engine = 'BLENDER_EEVEE'
return ground, cam, sun

---------- Collections (safe) ----------

def put_in_collection(name, objects):
coll = bpy.data.collections.get(name)
if not coll:
coll = bpy.data.collections.new(name)
bpy.context.scene.collection.children.link(coll)
for obj in objects:
# Unlink from any other collections
for c in obj.users_collection:
c.objects.unlink(obj)
coll.objects.link(obj)

---------- Main ----------

def build_car_scene():
reset_scene()
body = create_car_body()
wheels = add_wheels(body)
ground, cam, sun = setup_env()

# Organize
put_in_collection("Car", [body] + wheels)
put_in_collection("Env", [ground, cam, sun])

print("Blender 5.0: Simple car scene built.")

build_car_scene()

Hello, I don’t know what kind of results you’re expecting but modeling a car with a script is very difficult, if not impossible…
the closest things that could be done might be something a bit along the lines of character generators, that are using a bunch of pre-made assets that can vary their shapes. Then there is some script on top of that to help interact with those assets and put everything together…

So since probably there isn’t any working example in the internet of what you’re after, ChatGPT tries to fill the gap with tiny bits of what’s available in it’s database…

While AI is useful to write simple tools or could help in solving a specific problem , for now I never seen a good result with something advanced or more complex…

Thank You. You can see the “best” result I achieved after a long time. Maybe the future…

Well, I think it’s just not the proper solution to that problem…
If you need a car model there is many resources available already, even free models.

Now if you need a particular model that doesn’t exist, maybe it’s worth looking into image to model generation to get something…

But it’s also worth learning how to model that yourself, while AI allows to cut corners in the long run knowing how things works manually is always going to be useful.

Maybe You misunderstood me. I can model a car in Blender. But I was curious what AI can do!