Skip to content

Code for a random 3D model in Blender

Forlando · Jun 11, 2026
Jun 11, 2026
#2
import bpyfrom math import radians

Limpar cena


bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

Materiais


def make_material(name, color):

    mat = bpy.data.materials.new(name)

    mat.use_nodes = True

    bsdf = mat.node_tree.nodes["Principled BSDF"]

    bsdf.inputs["Base Color"].default_value = color

    return mat

skin = make_material("Skin", (0.55, 0.40, 0.28, 1))

shirt = make_material("Shirt", (0.15, 0.15, 0.17, 1))

pants = make_material("Pants", (0.18, 0.18, 0.20, 1))

hair = make_material("Hair", (0.08, 0.08, 0.10, 1))

eye = make_material("Eye", (1, 1, 1, 1))

shoe = make_material("Shoe", (0.05, 0.05, 0.05, 1))

Cabeça


bpy.ops.mesh.primitive_uv_sphere_add(radius=0.55, location=(0,0,2.4))

head = bpy.context.object

head.scale[1] = 0.9

head.data.materials.append(skin)

Tronco


bpy.ops.mesh.primitive_cube_add(location=(0,0,1.35))

body = bpy.context.object

body.scale = (0.45,0.25,0.7)

body.data.materials.append(shirt)

Pescoço


bpy.ops.mesh.primitive_cylinder_add(radius=0.12, depth=0.18, location=(0,0,1.9))

neck = bpy.context.object

neck.data.materials.append(skin)

Braços


for side in [-1,1]:

    bpy.ops.mesh.primitive_cube_add(location=(side*0.9,0,1.55))

    arm = bpy.context.object

    arm.scale = (0.55,0.12,0.12)

    arm.data.materials.append(skin)

Mãos


for side in [-1,1]:

    bpy.ops.mesh.primitive_uv_sphere_add(radius=0.16, location=(side*1.55,0,1.55))

    hand = bpy.context.object

    hand.scale = (1.2,0.7,0.5)

    hand.data.materials.append(skin)

Pernas


for side in [-0.18,0.18]:

    bpy.ops.mesh.primitive_cube_add(location=(side,0,0.45))

    leg = bpy.context.object

    leg.scale = (0.16,0.16,0.75)

    leg.data.materials.append(pants)

Sapatos


for side in [-0.18,0.18]:

    bpy.ops.mesh.primitive_cube_add(location=(side,0.08,-0.35))

    foot = bpy.context.object

    foot.scale = (0.22,0.30,0.10)

    foot.data.materials.append(shoe)

Olhos


for side in [-0.17,0.17]:

    bpy.ops.mesh.primitive_uv_sphere_add(radius=0.12, location=(side,0.48,2.45))

    e = bpy.context.object

    e.data.materials.append(eye)

    bpy.ops.mesh.primitive_uv_sphere_add(radius=0.05, location=(side,0.57,2.45))

    p = bpy.context.object

    p.data.materials.append(hair)

Orelhas


for side in [-0.55,0.55]:

    bpy.ops.mesh.primitive_uv_sphere_add(radius=0.12, location=(side,0,2.35))

    ear = bpy.context.object

    ear.scale[1] = 0.7

    ear.data.materials.append(skin)

Cabelo principal


bpy.ops.mesh.primitive_uv_sphere_add(radius=0.58, location=(0,0,2.7))

hair_cap = bpy.context.object

hair_cap.scale = (1.0,0.95,0.65)

hair_cap.data.materials.append(hair)

Pontas do cabelo


spikes = [

    (-0.25,0,3.15),

    (0.0,0,3.25),

    (0.25,0,3.12),

    (0.40,0,2.95)

]

for pos in spikes:

    bpy.ops.mesh.primitive_cone_add(

        radius1=0.12,

        depth=0.35,

        location=pos

    )

    spike = bpy.context.object

    spike.rotation_euler[0] = radians(15)

    spike.data.materials.append(hair)

Boca simples


bpy.ops.mesh.primitive_cube_add(location=(0,0.50,2.15))

mouth = bpy.context.object

mouth.scale = (0.12,0.01,0.01)

mouth.data.materials.append(hair)

print("Personagem criado com sucesso.")
Jun 11, 2026
#3
what does this do
Jun 11, 2026
#4
That's what I think because I haven't tested it.
Replying to @Forlando
Jun 12, 2026
#5
is this going to replace the stig?
Log in to reply.