Skip to content

menu.py - Technical Documentation

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

The menu.py file defines the main Pie Menu of DAMTools, allowing quick access to all the addon's tools from a radial menu (pie menu) invokable with Shift+W (or the configured shortcut). It also includes submenus and auxiliary operators for import and organization options.


Index


General Purpose

  • Defines the main pie menu of DAMTools and its submenus.
  • Allows quick access to all tools from the 3D Viewport.
  • Integrates auxiliary operators for advanced options.

File Structure

  1. Colors: Dictionary of colors for visual customization (optional).
  2. Import options operator: Allows displaying an options dialog before importing.
  3. Main Pie Menu: BATCHTOOLS_MT_MainMenu class with the radial structure and buttons.
  4. Arrange X (Alt) Submenu: Allows choosing between normal Arrange X and Arrange X with rotation reset.
  5. Registration of classes: List of classes to register in Blender.

Key Blocks and Explanation

Colors and Utilities

COLORS = {
    "blue": (0.2, 0.6, 1.0, 1.0),
    ...
}
- Dictionary of colors for visual customization (not essential for the menu).

Import Options Operator

class DAMTools_MT_ImportOptions(Operator):
    bl_idname = "DAMTools.import_options"
    ...
    def draw(self, context):
        # Draws import options in a dialog
- Allows displaying an options dialog before batch importing files.

Definition of the Main Pie Menu

class BATCHTOOLS_MT_MainMenu(Menu):
    bl_idname = "BATCHTOOLS_MT_main_menu"
    bl_label = "DAMTools"
    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        # Quadrant structure and buttons
- Defines the main pie menu, with sections for import, export, transform, help, branding, and QuickSnap access.

Arrange X (Alt) Submenu

class BATCHTOOLS_MT_arrange_x_alt_menu(Menu):
    bl_idname = "BATCHTOOLS_MT_arrange_x_alt_menu"
    ...
    def draw(self, context):
        # Allows choosing between normal arrange and arrange+rotation reset
- Allows choosing between normal Arrange X and Arrange X with rotation reset using Alt.

Registration of Classes

classes = (
    BATCHTOOLS_MT_MainMenu,
    DAMTools_MT_ImportOptions,
    BATCHTOOLS_MT_arrange_x_alt_menu,
)
- List of classes to register in Blender.


Key Code Snippets

Pie Menu Structure

class BATCHTOOLS_MT_MainMenu(Menu):
    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        # ...

QuickSnap Button in the Pie Menu

col_quicksnap_pie.operator("object.quicksnap", text="Activate QuickSnap (Ctrl+Shift+V)", icon='SNAP_ON')

Suggested Images

  • PLACE IMAGE OF menu.py SOURCE CODE IN THE EDITOR HERE
  • PLACE IMAGE OF THE OPEN PIE MENU IN BLENDER
  • PLACE DIAGRAM OF THE RADIAL MENU STRUCTURE

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