Skip to content

Instantly share code, notes, and snippets.

@Infinitusvoid
Last active August 30, 2023 16:01
Show Gist options
  • Save Infinitusvoid/9120586ecf167bb218449b96feee999f to your computer and use it in GitHub Desktop.
Save Infinitusvoid/9120586ecf167bb218449b96feee999f to your computer and use it in GitHub Desktop.
Blender Python : How to create two cubes, and apply remesh modifier to merge them ?
import bpy
# Create first cube
bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0))
# Create second cube
bpy.ops.mesh.primitive_cube_add(size=1, location=(1, 0, 0))
# Get the active object (the last one created)
obj = bpy.context.active_object
# Move the object along the x-axis
bpy.ops.transform.translate(value=(-0.5, 0, 0))
# Select both objects
bpy.data.objects["Cube"].select_set(True)
bpy.data.objects["Cube.001"].select_set(True)
# Join the objects
bpy.ops.object.join()
# Add the Remesh modifier
mod = obj.modifiers.new(name="Remesh", type="REMESH")
# Set the remesh mode to "Smooth"
mod.mode = "SMOOTH"
# Apply the modifier
bpy.ops.object.modifier_apply(modifier="Remesh")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment