{"id":12077,"date":"2026-03-18T21:55:34","date_gmt":"2026-03-19T02:55:34","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=12077"},"modified":"2026-03-19T09:17:21","modified_gmt":"2026-03-19T14:17:21","slug":"blender-scripting-lesson-of-the-week-beveling","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=12077","title":{"rendered":"Blender Scripting Lesson of the Week: Beveling"},"content":{"rendered":"\n<p>We were playing around with bevels this week &#8211; it&#8217;s pretty straight forward, the API lets you set the parameters you set through the GUI in a bevel modifier. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport bpy\n\n# Clear all existing objects\nfor obj in list(bpy.data.objects):\n    bpy.data.objects.remove(obj, do_unlink=True)\n\n# Set Units\nscene = bpy.context.scene\nscene.unit_settings.system = &#039;METRIC&#039;\nscene.unit_settings.scale_length = 0.001  # 1 BU = 1 mm\n\n# Create rectangular cube\nbpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))\nblock = bpy.context.active_object\nblock.name = &quot;Block&quot;\n\n# cube default size is 2x2x2, so set absolute dimensions\nblock.dimensions = (2.0, 20.0, 0.25)\nbpy.context.view_layer.objects.active = block\nblock.select_set(True)\n\n# Apply scale so booleans\/bevel behave predictably\nbpy.ops.object.transform_apply(location=False, rotation=False, scale=True)\n\n# Create cylinder cutter\nhole_diameter = 1.0\nhole_radius = hole_diameter \/ 2.0\n\n# Make it longer than the block thickness so it fully cuts through\ncutter_depth = 5.0\n\nbpy.ops.mesh.primitive_cylinder_add(\n    vertices=64,\n    radius=hole_radius,\n    depth=cutter_depth,\n    location=(0.0, 0.0, 0.0),   # center of the block\n    rotation=(0.0, 0.0, 0.0)\n)\ncutter = bpy.context.active_object\ncutter.name = &quot;HoleCutter&quot;\n\nbpy.ops.object.transform_apply(location=False, rotation=False, scale=True)\n\n# Boolean: cut hole\nbpy.context.view_layer.objects.active = block\nbool_mod = block.modifiers.new(name=&quot;Hole&quot;, type=&#039;BOOLEAN&#039;)\nbool_mod.operation = &#039;DIFFERENCE&#039;\nbool_mod.solver = &#039;EXACT&#039;\nbool_mod.object = cutter\n\n# Apply boolean\nbpy.ops.object.modifier_apply(modifier=bool_mod.name)\n\n# Hide cutter in viewport + renders\ncutter.hide_set(True)\ncutter.hide_render = True\n\n# Bevel the block\nbevel_width = 0.08 \nbevel_segments = 5\n\nbevel_mod = block.modifiers.new(name=&quot;Bevel&quot;, type=&#039;BEVEL&#039;)\nbevel_mod.width = bevel_width\nbevel_mod.segments = bevel_segments\nbevel_mod.limit_method = &#039;ANGLE&#039;\nbevel_mod.angle_limit = 0.523599  # 30 degrees in radians\n\n# Apply bevel\nbpy.ops.object.modifier_apply(modifier=bevel_mod.name)\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>We were playing around with bevels this week &#8211; it&#8217;s pretty straight forward, the API lets you set the parameters you set through the GUI in a bevel modifier.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2163,1945],"tags":[2178,2179,2158,2177],"class_list":["post-12077","post","type-post","status-publish","format-standard","hentry","category-blender-3d-printing","category-python","tag-bevel","tag-beveling","tag-blender","tag-bpy"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12077"}],"version-history":[{"count":3,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12077\/revisions"}],"predecessor-version":[{"id":12086,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12077\/revisions\/12086"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}