Can you write me a blender script to make a donut?
- User
Can you write me a blender script to make a donut?
- Assistant
Sure! Here's a Blender script that generates a donut:
import bpy import numpy as np 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 * np.cos(2 * np.pi * i / resolution), thickness * np.sin(2 * np.pi * i / resolution), 0) for i in range(resolution)] inner_circle = [(radius * 0.6 + thickness * np.cos(2 * np.pi * i / resolution), thickness * np.sin(2 * np.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 object = bpy.data.objects.new("donut", mesh) bpy.context.scene.collection.objects.link(object)This script creates a donut mesh with the specified radius and thickness, and a resolution of 32 vertices per circle. It then creates the faces between the circles and generates the mesh. Finally, it creates the object and links it to the scene. You can adjust the parameters to generate different sizes and styles of donuts.
- User
How would I load this script into Blender?
- Assistant
To load the script into Blender:
Open Blender and switch to the "Text Editor" workspace by selecting "Text Editor" from the top-left drop-down menu. In the "Text Editor" workspace, click on the "New" button to create a new text file. Copy and paste the script code into the new text file. Save the script file by clicking on "File" -> "Save" or by pressing "Ctrl + S" (Windows/Linux) or "Cmd + S" (Mac). Run the script by clicking on the "Run Script" button (looks like a "Play" button) or by pressing "F5". Alternatively, you can also run the script by selecting "Text" -> "Run Script" from the top menu or by pressing "Alt + P" in the "Text Editor" workspace. Once you run the script, Blender will create the donut mesh and add it to the scene. You can then modify and manipulate the donut mesh as you would with any other Blender object.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)