Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created August 28, 2023 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGArtPython/3fcc2878e3d3c528f11e2567f6ea2a67 to your computer and use it in GitHub Desktop.
Save CGArtPython/3fcc2878e3d3c528f11e2567f6ea2a67 to your computer and use it in GitHub Desktop.
Blender Python script that bevels the edges of an active object that is in OBJECT mode (see tutorial here: https://youtu.be/TFQMNcTj5Jw)
import bpy
import bmesh
# get a reference to the active object
mesh_obj = bpy.context.active_object
# create a new bmesh
bm = bmesh.new()
# initialize the bmesh data using the mesh data
bm.from_mesh(mesh_obj.data)
bmesh.ops.bevel(
bm,
geom=bm.edges,
offset=0.2,
segments=4,
affect="EDGES",
profile=0.5,
)
bm.normal_update()
# writes the bmesh data into the mesh data
bm.to_mesh(mesh_obj.data)
# [Optional] update the mesh data (helps with redrawing the mesh in the viewport)
mesh_obj.data.update()
# clean up/free memory that was allocated for the bmesh
bm.free()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment