Special welcome gift. Get 30% off your first purchase with code “REALCG”. Find out more!

Automate Boring Blender Tasks using ChatGPT

In this tutorial, I’ll show you how to use ChatGPT to automate repetitive tasks in Blender, saving you valuable time in your workflow. Additionally, I’ll demonstrate how to convert these scripts into actual Blender add-ons. This can be incredibly useful for streamlining tasks, like adding modifiers.

In this example, I’ll focus on creating a simple Blender add-on that automates the process of adding a bevel modifier to objects. I often add a bevel modifier to avoid sharp edges, repeating the same steps over and over: adding the modifier, setting the segments to three, adjusting the bevel amount based on the object, and applying smooth shading.

With a little automation, we can do all of this with a single click of a button using ChatGPT! Let’s dive in.


Automating Repetitive Tasks with ChatGPT

  1. The Task: In Blender, I frequently add the Bevel modifier to objects. The process involves setting the segments to three, adjusting the bevel amount, and then applying shade smooth. It’s a repetitive task that can be automated to save time.
  2. Creating the Script: Using ChatGPT, I’ll automate these steps by generating a Python script that does the work for us.

Step 1: Writing the Python Script with ChatGPT

Blender uses Python as its scripting language, so we can ask ChatGPT to generate a script that adds a bevel modifier to selected objects. I’ll instruct ChatGPT to do the following:

  • Write a Python script for a Blender add-on called “Bevy.”
  • This add-on will add a button labeled “Let’s Bevel” to the Blender interface.
  • The button will appear in the Item panel on the right-hand side of the viewport.
  • When clicked, the button will add a bevel modifier with segments set to 3 and allow dynamic adjustment of the bevel amount.
  • Finally, the script will apply Shade Smooth to the object.

Here’s the command I give to ChatGPT:

“Write a Python script for a Blender add-on called ‘Bevy’ that adds a button labeled ‘Let’s Bevel’ in the Item panel. When pressed, it should add a bevel modifier to the selected object with segments set to 3, an adjustable bevel amount starting at 0.075, and apply Shade Smooth.”


Step 2: Implementing the Python Script in Blender

Once ChatGPT generates the code, I’ll copy the script into Blender’s scripting panel. Here’s how to do that:

  1. Open Blender and go to the Scripting tab.
  2. In the text editor, create a new script, name it “Bevy.”
  3. Paste the generated Python code from ChatGPT.
  4. Click on Run Script to execute the code.

After running the script, you’ll notice a new option in the Item panel with a button labeled “Let’s Bevel.”

Here’s the generated Python code for “Bevelify” addon:

bl_info = {
"name": "Bevelify",
"author": "Your Name",
"version": (1, 0),
"blender": (2, 80, 0),
"description": "Adds a bevel modifier to the selected object",
"category": "Object",
}

import bpy

class BevelifyProperties(bpy.types.PropertyGroup):
bevel_amount: bpy.props.FloatProperty(
name="Bevel Amount",
description="Width of the bevel",
default=0.025,
min=0.0,
max=1.0,
subtype='DISTANCE',
unit='LENGTH'
)

class OBJECT_OT_bevelify(bpy.types.Operator):
bl_idname = "object.bevelify"
bl_label = "Bevelify"
bl_options = {'REGISTER', 'UNDO'}

def execute(self, context):
obj = context.active_object
if obj is None or obj.type != 'MESH':
self.report({'WARNING'}, "No mesh object selected")
return {'CANCELLED'}

bevel_modifier = obj.modifiers.new(name="Bevel", type='BEVEL')
bevel_modifier.width = context.scene.bevelify_props.bevel_amount
bevel_modifier.segments = 3

bpy.ops.object.shade_smooth()

return {'FINISHED'}

class OBJECT_PT_bevelify_panel(bpy.types.Panel):
bl_label = "Bevelify"
bl_idname = "OBJECT_PT_bevelify"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Item'

def draw(self, context):
layout = self.layout
scene = context.scene

layout.operator("object.bevelify")

layout.prop(scene.bevelify_props, "bevel_amount")

def register():
bpy.utils.register_class(OBJECT_OT_bevelify)
bpy.utils.register_class(OBJECT_PT_bevelify_panel)
bpy.utils.register_class(BevelifyProperties)
bpy.types.Scene.bevelify_props = bpy.props.PointerProperty(type=BevelifyProperties)

def unregister():
bpy.utils.unregister_class(OBJECT_OT_bevelify)
bpy.utils.unregister_class(OBJECT_PT_bevelify_panel)
bpy.utils.unregister_class(BevelifyProperties)
del bpy.types.Scene.bevelify_props

if __name__ == "__main__":
register()

Step 3: Testing the Add-On in Blender

Now let’s see the add-on in action:

  1. Press Shift + A to add a new object (e.g., a cube).
  2. Select the cube and click on the “Let’s Bevel” button.
  3. The bevel modifier is applied with segments set to 3, and you can dynamically adjust the bevel amount.

Additionally, the Shade Smooth function is applied, ensuring clean geometry. This automation can save you tons of time, especially in more complex scenes where beveling multiple objects is necessary.


Step 4: Turning the Script into a Blender Add-On

To turn this script into an official Blender add-on that can be installed:

  1. Copy the Python script and paste it into a text editor (e.g., Notepad).
  2. Save the file with the name __init__.py.
  3. Place this file inside a new folder named Bevy.
  4. Right-click the folder and convert it into a ZIP file.

Now you can install this add-on in Blender by going to Edit > Preferences > Add-ons, clicking Install, and selecting the ZIP file. Once installed, the add-on will appear under your add-ons list, and you can activate it.


Conclusion: The Power of ChatGPT & Blender Automation

By following these steps, you can easily create a simple Blender add-on that automates repetitive tasks like adding bevel modifiers. With the help of ChatGPT, you can create custom scripts, saving time and enhancing productivity.

This example demonstrates how useful automation can be in Blender, especially when dealing with repetitive actions. If you found this tutorial helpful, please give it a thumbs up and stay tuned for more automation tips and Blender tricks in future projects!


Click the button to download “Bevelify.zip” addon…




Abdelilah Hamdani is a 3D Designer and a Developer. I firmly believe that Photorealism is gonna be one of the most valuable skills in the near future. There is alot of opportunities for CGI artists: VFX, Gaming, Movies & Series. More than 6 years in the 3D Industry and i humbly admit i've got alot more to learn.

Leave A Reply

Your email address will not be published. Required fields are marked *