Untitled

Anonymous
plain_text
02/22/2026 6:42 PM
2.9 KB
8
Indexable
import bpy
import math

# Clear scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

# ---------- MATERIALS ----------
green = bpy.data.materials.new(name="Green")
green.diffuse_color = (0.05, 0.6, 0.05, 1)

yellow = bpy.data.materials.new(name="Yellow")
yellow.diffuse_color = (1, 0.8, 0, 1)

black = bpy.data.materials.new(name="Black")
black.diffuse_color = (0.02, 0.02, 0.02, 1)

# ---------- BODY ----------
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 1))
body = bpy.context.object
body.scale = (3, 1.5, 1)
body.data.materials.append(green)

# ---------- CABIN ----------
bpy.ops.mesh.primitive_cube_add(size=2, location=(-1.2, 0, 2.4))
cabin = bpy.context.object
cabin.scale = (1.5, 1.3, 1)
cabin.data.materials.append(green)

# ---------- SEAT ----------
bpy.ops.mesh.primitive_cube_add(size=1, location=(-1.2, 0, 2))
seat = bpy.context.object
seat.scale = (0.8, 0.8, 0.3)
seat.data.materials.append(yellow)

# ---------- EXHAUST PIPE ----------
bpy.ops.mesh.primitive_cylinder_add(radius=0.15, depth=3, location=(1.5, 0.8, 2.5))
pipe = bpy.context.object
pipe.data.materials.append(black)

# ---------- WHEEL FUNCTION ----------
def create_wheel(x, y, z, radius):
    bpy.ops.mesh.primitive_cylinder_add(radius=radius, depth=0.8, location=(x, y, z))
        wheel = bpy.context.object
            wheel.rotation_euler[0] = math.radians(90)
                wheel.data.materials.append(black)

                    # Rim
                        bpy.ops.mesh.primitive_cylinder_add(radius=radius*0.5, depth=0.85, location=(x, y, z))
                            rim = bpy.context.object
                                rim.rotation_euler[0] = math.radians(90)
                                    rim.data.materials.append(yellow)

                                    # Rear wheels
                                    create_wheel(2.5, 1.8, 0.8, 1)
                                    create_wheel(2.5, -1.8, 0.8, 1)

                                    # Front wheels
                                    create_wheel(-2.5, 1.8, 0.6, 0.6)
                                    create_wheel(-2.5, -1.8, 0.6, 0.6)

                                    print("Advanced 3D Tractor Created Successfully!")
Editor is loading...
Leave a Comment