Created
March 12, 2019 14:55
-
-
Save nezuppo/81206dff062c0d37a96dcc8324bee29b to your computer and use it in GitHub Desktop.
blender で切り抜き
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
# まずは全て削除 | |
bpy.ops.object.select_all(action='SELECT') | |
bpy.ops.object.delete(True) | |
# キューブを作成 | |
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0)) | |
cube_object = bpy.context.object | |
cube_object.dimensions = (5, 5, 1) | |
# 切り抜き用のシリンダー作成 | |
bpy.ops.mesh.primitive_cylinder_add(vertices=100, radius=2, depth=2, | |
location=(0, 0, 0)) | |
cylinder_object = bpy.context.object | |
# キューブからシリンダーを抜く | |
bpy.context.scene.objects.active = cube_object | |
boolean = cube_object.modifiers.new('cube-boolean', 'BOOLEAN') | |
boolean.operation = 'DIFFERENCE' | |
boolean.object = cylinder_object | |
bpy.ops.object.modifier_apply(modifier='cube-boolean') | |
# 切り抜いた後の不要になったシリンダー削除 | |
bpy.context.scene.objects.unlink(cylinder_object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment