Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

Can you write me a blender script to make a donut?

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    Can you write me a blender script to make a donut?

  2. Assistant

    Certainly! Here's an example of a Blender Python script to create a donut mesh:

    import bpy
    import math
    
    # Set the radius and thickness of the donut
    radius = 1
    thickness = 0.5
    
    # Set the number of vertices per circle
    resolution = 32
    
    # Create the outer and inner circles
    outer_circle = [(radius + thickness * math.cos(2 * math.pi * i / resolution), thickness * math.sin(2 * math.pi * i / resolution), 0) for i in range(resolution)]
    inner_circle = [(radius * 0.6 + thickness * math.cos(2 * math.pi * i / resolution), thickness * math.sin(2 * math.pi * i / resolution), 0) for i in range(resolution)]
    
    # Create the faces between the circles
    faces = []
    for i in range(resolution):
        face = (i, (i + 1) % resolution, ((i + 1) % resolution) + resolution, i + resolution)
        faces.append(face)
    
    # Create the mesh
    mesh = bpy.data.meshes.new("Donut")
    mesh.from_pydata(outer_circle + inner_circle, [], faces)
    
    # Create the object and link it to the scene
    obj = bpy.data.objects.new("Donut", mesh)
    bpy.context.scene.collection.objects.link(obj)
    

    This script uses Blender's bpy module to create a donut mesh with the specified radius, thickness, and resolution. It creates two circles (outer and inner) using trigonometric calculations, and then defines the faces between the circles. Finally, it creates a mesh object from the vertex and face data, and links it to the Blender scene.

    You can run this script within Blender's Text Editor, or by saving it as a .py file and using the "Scripting" workspace in Blender to run it. It will create a donut object in the Blender scene.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.

Can you write me a blender script to make a donut? · The Chat Archive