←back to thread

Blender 4.3

(www.blender.org)
239 points antome | 2 comments | | HN request time: 0.526s | source
Show context
xiaomai ◴[] No.42191431[source]
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): >>42191477 #>>42191478 #>>42191482 #>>42191561 #>>42191878 #>>42191933 #>>42192064 #
1. timonoko ◴[] No.42191933[source]
Best way is to steal somebody else's model and improve it to your taste. That is the main use of Blender in 3D-printing, because parametric modelling is not the best property in Blender. Although it is almost feasible to define OpenSCAD model and ask AI to redefine in blender-python.

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)
replies(1): >>42192002 #
2. timonoko ◴[] No.42192002[source]
It seems to be "empty" in name only. Lets try again.

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)