Логотип Operators

Operators

Спільнота
TMHSDigital
operators

Author bpy.types.Operator classes: bl_idname naming, poll / invoke / execute / modal lifecycle, bl_options (REGISTER, UNDO, INTERNAL, BLOCKING), operator properties and defensive context handling. Use when the user creates an operator for a button, menu, keymap or script, asks why its properties are missing from the Adjust Last Operation (redo) panel or why Ctrl-Z ignores it, or gets poll failures or None context objects. Targets 5.2 LTS with 4.5 LTS compatibility.

Огляд

ВидавецьTMHSDigital
РепозиторійBlender-Developer-Tools
Назва навичкиoperators
Зірки
20
Форки
5
Файли в пакеті
Лише інструкції
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Усе необхідне — в інструкціях

    Усе потрібне моделі міститься в інструкціях — жодних додаткових файлів для синхронізації.

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем TMHSDigital. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Operators у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/skills/operators
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TMHSDigital/Blender-Developer-Tools.git /tmp/Blender-Developer-Tools
mkdir -p .claude/skills
cp -r /tmp/Blender-Developer-Tools/skills/operators .claude/skills/operators
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Operators в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Operators, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції Markdown, а не код для певного постачальника, тому навичка Operators не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож невикористана навичка нічого не коштує.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Operators

Trigger

Use this skill when the user:

  • Wants to create a new bpy.types.Operator
  • Mentions bl_idname, bl_label, bl_options, "redo panel", "F6 panel", "operator props"
  • Needs an action triggered from a button, menu, keymap, or chat command
  • Asks why their operator's properties don't show up in the redo panel

Required inputs

  • Action category: the prefix of bl_idname (mesh, object, scene, view3d, etc.)
  • Operator name: the suffix (my_addon_action)
  • Class name: the conventional CATEGORY_OT_name (MESH_OT_my_addon_action)
  • Whether the action is undoable (most are)

Anatomy of a Blender operator

python
import bpy


class MESH_OT_offset_along_normals(bpy.types.Operator):
    bl_idname = "mesh.offset_along_normals"
    bl_label = "Offset Along Normals"
    bl_description = "Move every vertex of the active mesh a fixed distance along its normal"
    bl_options = {'REGISTER', 'UNDO'}

    distance: bpy.props.FloatProperty(
        name="Distance",
        description="How far to move each vertex",
        default=0.5,
        min=-100.0,
        max=100.0,
        unit='LENGTH',
    )

    @classmethod
    def poll(cls, context):
        obj = context.active_object
        return obj is not None and obj.type == 'MESH' and obj.mode == 'OBJECT'

    def execute(self, context):
        obj = context.active_object
        if obj is None:
            self.report({'ERROR'}, "No active object")
            return {'CANCELLED'}

        # Operate on bpy.data, not bpy.ops, and in bulk: one foreach_get /
        # foreach_set pair instead of a Python loop over mesh.vertices (rule
        # use-foreach-set-for-bulk-data). See the mesh-editing-and-bmesh skill.
        mesh = obj.data
        n = len(mesh.vertices)
        co = [0.0] * (n * 3)
        nor = [0.0] * (n * 3)
        mesh.vertices.foreach_get("co", co)
        mesh.vertices.foreach_get("normal", nor)
        d = self.distance
        mesh.vertices.foreach_set("co", [c + k * d for c, k in zip(co, nor)])

        mesh.update()
        self.report({'INFO'}, f"Offset {n} vertices by {d:.3f}")
        return {'FINISHED'}

The lifecycle methods

MethodRequiredCalled whenReturns
poll(cls, context)OptionalEvery UI redraw to decide if the operator is enabled. Must be cheap.True to enable, False or falsy to disable
invoke(self, context, event)OptionalThe user triggers the operator interactively (button, menu, keymap). Default forwards to execute.{'FINISHED'}, {'CANCELLED'}, {'PASS_THROUGH'}, {'RUNNING_MODAL'}
execute(self, context)YesThe operator runs, either after invoke or directly via bpy.ops.mesh.offset_along_normals(){'FINISHED'} or {'CANCELLED'}
modal(self, context, event)OptionalAfter invoke returns {'RUNNING_MODAL'}. Called for each event until you return {'FINISHED'} or {'CANCELLED'}.Standard return set
draw(self, context)OptionalThe redo panel after the operator runs. Defaults to drawing all properties.None

poll must be fast

poll runs on every UI redraw. Do not iterate the scene, scan meshes, or call modifiers there. Restrict yourself to context.active_object, obj.type, obj.mode, and similar O(1) checks.

bl_options you almost always want

  • 'REGISTER': reports the operator in the Info editor and enables the Adjust Last Operation (redo) panel. Without it, properties cannot be tweaked after running. It does not add an undo step; that is 'UNDO'.
  • 'UNDO': hooks into the undo stack. Without this, your operator's effect cannot be undone with Ctrl-Z.
  • 'INTERNAL': hides the operator from operator search. Use for operators called only by other operators or panels. It still runs from Python and buttons.
  • 'BLOCKING': blocks anything else from using the cursor while the operator runs. Reserve for modal operators that need exclusive mouse input.
  • 'GRAB_CURSOR' and 'GRAB_CURSOR_X' / 'GRAB_CURSOR_Y': useful in modal operators to capture mouse motion.

Defensive context handling

context.active_object returns None only when there is no active object:

  • An empty scene, such as after read_factory_settings(use_empty=True), or a file whose view layer never had one.
  • The active object was deleted.
  • A context override sets active_object=None deliberately.

It is not None just because nothing is selected, and not just because Blender runs headless. Measured on 4.5.11 and 5.2.1 (--background --factory-startup): the startup scene's active object is Cube, and after bpy.ops.object.select_all(action='DESELECT') it is still Cube, with selected_objects == [] and Cube.select_get() == False.

Active and selected are independent. That is the real pitfall: an active object that is not selected, hidden, or not editable. A None guard does not catch it. Operators that act on the selection then run on nothing, or on the wrong set, without raising. Measured: bpy.ops.object.delete() with the Cube active but deselected returns {'CANCELLED'} and the Cube survives. When the operation needs selection, check obj.select_get() or work from context.selected_objects. Check obj.visible_get() before acting on what the user sees. Check obj.library is None (and obj.override_library if you edit overrides) before writing to linked data.

Always guard before dereferencing:

python
def execute(self, context):
    obj = context.active_object
    if obj is None:
        self.report({'ERROR'}, "No active object")
        return {'CANCELLED'}
    if obj.type != 'MESH':
        self.report({'ERROR'}, f"{obj.name} is a {obj.type}, expected MESH")
        return {'CANCELLED'}
    if not obj.select_get():  # active is not selected after a deselect-all
        self.report({'ERROR'}, f"{obj.name} is active but not selected")
        return {'CANCELLED'}
    # ...

Even if poll already filtered, execute must re-check, because execute is also reachable from bpy.ops calls in scripts that bypass the UI.

Reporting back to the user

Use self.report({level}, message) rather than print():

LevelUI behavior
'DEBUG'Visible only in developer mode
'INFO'Status bar, info window
'WARNING'Status bar with yellow tint, info window
'ERROR'Status bar with red tint, info window
'ERROR_INVALID_INPUT'Same as ERROR but signals input was the cause

Pair report({'ERROR'}, ...) with return {'CANCELLED'} so the operator does not appear successful.

Worked example: a redo-friendly operator with a redo panel

python
import bpy
from mathutils import Vector


class OBJECT_OT_offset_active(bpy.types.Operator):
    bl_idname = "object.offset_active"
    bl_label = "Offset Active Object"
    bl_options = {'REGISTER', 'UNDO'}

    offset_x: bpy.props.FloatProperty(name="X", default=0.0, unit='LENGTH')
    offset_y: bpy.props.FloatProperty(name="Y", default=0.0, unit='LENGTH')
    offset_z: bpy.props.FloatProperty(name="Z", default=1.0, unit='LENGTH')
    use_local: bpy.props.BoolProperty(
        name="Local Axes",
        description="Offset along object's local axes instead of world axes",
        default=False,
    )

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        obj = context.active_object
        if obj is None:
            return {'CANCELLED'}

        offset = (self.offset_x, self.offset_y, self.offset_z)

        if self.use_local:
            # Column-normalize the basis so object scale does not distort the
            # local-axis direction; to_3x3() alone carries scale into the result.
            basis = obj.matrix_world.to_3x3().normalized()
            obj.location += basis @ Vector(offset)
        else:
            obj.location.x += self.offset_x
            obj.location.y += self.offset_y
            obj.location.z += self.offset_z

        return {'FINISHED'}

After running this operator from the menu, the user gets a redo panel in the bottom-left of the 3D viewport with sliders for offset_x/y/z and a use_local toggle. Adjusting them re-runs execute. This works only because 'REGISTER' is in bl_options and the properties are declared as annotations, not assignments (see the custom-properties skill).

Common AI mistakes

  1. Returning True / False from execute. The required return is the set {'FINISHED'} or {'CANCELLED'}. Returning a bool will raise.

  2. Forgetting 'UNDO' in bl_options. The operator runs but the user cannot reverse it.

  3. Slow poll that walks the scene, evaluates the depsgraph, or imports modules. Causes UI lag.

  4. Properties as assignments:

    python
    # WRONG: the property is class-level data, not a typed annotation
    class Bad(bpy.types.Operator):
        distance = bpy.props.FloatProperty(default=0.5)
    
    # RIGHT: annotation form, what 2.8+ requires
    class Good(bpy.types.Operator):
        distance: bpy.props.FloatProperty(default=0.5)

    The assignment form silently does not register the property in some Blender versions and breaks the redo panel in all of them.

  5. No bl_idname or a bl_idname without a category prefix (my_action instead of mesh.my_action). Blender requires the category.name shape.

  6. Calling bpy.ops.<other> from execute for bulk work. Each bpy.ops call triggers a depsgraph evaluation. Operate directly on bpy.data or via bmesh instead. See the prefer-data-over-ops-in-loops rule.

Related

  • addon-scaffolding for the registration pattern around your operator class
  • custom-properties for the annotation form
  • mesh-editing-and-bmesh for what to do inside execute for mesh work
  • Rule prefer-data-over-ops-in-loops
  • Rule type-annotate-props-and-defend-context

Runnable examples

Each example runs headless, asserts the contract, and exits non-zero when it breaks. Run one with blender --background --python <script> --; pass a falsifier flag to watch the check fail.

  • prop-origin-transform: Street pedestal origin-to-base-center + data-API scale apply + matrix_parent_inverse for a flanged conduit elbow. Falsify: --skip-mpi (exit 8).
  • temp-override-join: Join seven lantern parts into one object under bpy.context.temp_override — the supported replacement for the removed context.copy() dict-pass form. Falsify: --no-override (exit 3).
  • timers-modal-threading: Proves the event-loop contracts behind long-running add-on work. Falsify: --windowed-background-child (exit 3).

References

Поширені запитання

Що робить навичка ШІ Operators?

Author bpy.types.Operator classes: bl_idname naming, poll / invoke / execute / modal lifecycle, bl_options (REGISTER, UNDO, INTERNAL, BLOCKING), operator properties and defensive context handling. Use when the user creates an operator for a button, menu, keymap or script, asks why its properties are missing from the Adjust Last Operation (redo) panel or why Ctrl-Z ignores it, or gets poll failures or None context objects. Targets 5.2 LTS with 4.5 LTS compatibility.

Навіщо використовувати Operators у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Operators — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Operators у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/skills/operators. TypingMind прочитає файл SKILL.md і встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Operators?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Operators?

Зі скількома забажаєте. Якщо модель підтримує навички, ви можете використовувати з нею Operators — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama та інші — усе в TypingMind із власними ключами API.

Чи безкоштовна навичка ШІ Operators?

Навичку опубліковано на GitHub: TMHSDigital. Умови ліцензування дивіться в репозиторії. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це багаторазовий набір інструкцій, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти для виклику — код, який десь виконується й повертає результат. Натомість навичка ШІ надає моделі знання та порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇