What's the best way to get started with Blender these days? I'm mostly interested in making art and possibly even 3d printing some stuff (do these skills overlap at all?).
replies(7):
Hey ChatGPT, how you define an empty box in Blender Python?
import bpy
empty = bpy.data.objects.new("Empty_Box", None)
empty.empty_display_type = 'CUBE'
empty.empty_display_size = 1.0
bpy.context.collection.objects.link(empty)
ChatGPT: The OpenSCAD statement difference(){ cube(11); cube(10); } creates a shape by subtracting a smaller cube (10x10x10) from a larger cube (11x11x11). Here's how you can create the same effect in Blender using its Python API:
import bpy
import bmesh
# Create the larger cube
bpy.ops.mesh.primitive_cube_add(size=11, location=(0, 0, 0))
cube1 = bpy.context.object
# Create the smaller cube
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 0))
cube2 = bpy.context.object
# Add a Boolean modifier to subtract the smaller cube from the larger cube
mod_bool = cube1.modifiers.new(name="Boolean", type='BOOLEAN')
mod_bool.operation = 'DIFFERENCE'
mod_bool.object = cube2
# Apply the Boolean modifier
bpy.context.view_layer.objects.active = cube1
bpy.ops.object.modifier_apply(modifier=mod_bool.name)
# Remove the smaller cube from the scene
bpy.data.objects.remove(cube2)