Skip to content

operators.py - Technical Documentation

PLACE IMAGE OF operators.py SOURCE CODE IN THE EDITOR HERE

The operators.py file defines the main operators of DAMTools. Operators are executable actions (such as import, export, align, duplicate, etc.) that can be invoked from the sidebar panel, pie menu, or keyboard shortcuts.


Index


General Purpose

  • Defines the main operators (actions) of the DAMTools addon.
  • Allows executing actions from the panel, pie menu, or shortcuts.
  • Integrates the logic of each tool (import, export, QuickSnap, etc).

File Structure

  1. Definition of main operators: Classes for each action (import, export, align, organize, etc).
  2. Integration with panels and menus: Methods to invoke operators from the UI.
  3. Registration of classes: List of operators to register in Blender.

Key Blocks and Explanation

Definition of Main Operators

class DAMTools_OT_BatchImport(Operator):
    bl_idname = "DAMTools.batch_import"
    bl_label = "Batch Import"
    def execute(self, context):
        # Batch import logic
- Operator for batch importing files.

class DAMTools_OT_BatchExport(Operator):
    bl_idname = "DAMTools.batch_export"
    bl_label = "Batch Export"
    def execute(self, context):
        # Batch export logic
- Operator for batch exporting files.

Integration with Panels and Menus

layout.operator("DAMTools.batch_import", text="Batch Import", icon='IMPORT')
- Allows invoking the operator from the UI.

Registration of Classes

classes = (
    DAMTools_OT_BatchImport,
    DAMTools_OT_BatchExport,
    # ...other operators
)
- List of operators to register in Blender.


Key Code Snippets

Example of Modal Operator

class DAMTools_OT_AlignFloor(Operator):
    bl_idname = "DAMTools.align_floor"
    bl_label = "Align Floor"
    def modal(self, context, event):
        # Modal logic for interactive alignment

Example of Simple Operator

class DAMTools_OT_JoinNearby(Operator):
    bl_idname = "DAMTools.join_nearby"
    bl_label = "Join Nearby"
    def execute(self, context):
        # Logic for joining nearby objects

Suggested Images

  • PLACE IMAGE OF operators.py SOURCE CODE IN THE EDITOR HERE
  • PLACE IMAGE OF AN OPERATOR IN ACTION IN BLENDER
  • PLACE DIAGRAM OF A MODAL OPERATOR FLOW

To see the integration with each tool, consult the documentation for the corresponding modules in the [DOCUMENTATION] folder.