Skip to content

Instantly share code, notes, and snippets.

@pyrohmstr
Created June 23, 2021 14:56
Show Gist options
  • Select an option

  • Save pyrohmstr/aa7fa82767a813a6ddc6358922ba7d54 to your computer and use it in GitHub Desktop.

Select an option

Save pyrohmstr/aa7fa82767a813a6ddc6358922ba7d54 to your computer and use it in GitHub Desktop.
import bpy
import math
cutter = "48T"
part = "Cylinder"
step_degree = 5
ratio = 2 #cutter to part - do 1 full rotation of PART
end = int(360/step_degree)
print(end)
for i in range(1,end):
bpy.context.view_layer.objects.active = bpy.data.objects[part]
bdiff = bpy.context.object.modifiers.new('B0','BOOLEAN')
bdiff.object = bpy.data.objects[cutter]
bdiff.operation = 'DIFFERENCE'
bpy.ops.object.modifier_apply(modifier="B0")
r_cutter = math.radians(i*step_degree/ratio)
r_part = math.radians(-i*step_degree)
bpy.context.view_layer.objects.active = bpy.data.objects[cutter]
bpy.context.object.rotation_euler = (0,0,r_cutter)
bpy.context.view_layer.objects.active = bpy.data.objects[part]
bpy.context.object.rotation_euler = (0,0,r_part)
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment