Skip to content

ui.py - Technical Documentation

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

The ui.py file defines the sidebar panel (N-Panel) of DAMTools in Blender's 3D Viewport. This panel groups and organizes all the addon's tools, allowing intuitive and visual access to each function, including QuickSnap options and configurable shortcuts.


Index


General Purpose

  • Defines the DAMTools sidebar panel in the 3D Viewport.
  • Organizes and groups all addon tools for quick access.
  • Allows accessing QuickSnap and configuring shortcuts from the panel.

File Structure

  1. Main panel definition: DAMTools_PT_MainPanel class that creates the tab and the general layout.
  2. Tool integration: Adds buttons and sections for each tool (import, export, align, organize, etc.).
  3. QuickSnap section: Button and options to activate QuickSnap from the panel.
  4. Shortcuts and preferences: Displays and allows configuring shortcuts from the panel.
  5. Registration of classes: List of classes to register in Blender.

Key Blocks and Explanation

Definition of the Main Panel

class DAMTools_PT_MainPanel(Panel):
    bl_label = "DAMTools"
    bl_idname = "DAMTools_PT_main_panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "DAMTools"
    def draw(self, context):
        layout = self.layout
        # ...
- Defines the main panel in the DAMTools tab of the N-Panel.

Tool Integration

layout.operator("DAMTools.batch_import", text="Batch Import", icon='IMPORT')
layout.operator("DAMTools.batch_export", text="Batch Export", icon='EXPORT')
# ...
- Adds buttons for each addon tool.

QuickSnap Section

box_quicksnap = layout.box()
box_quicksnap.label(text="QuickSnap", icon='SNAP_ON')
box_quicksnap.operator("object.quicksnap", text="Activate QuickSnap (Ctrl+Shift+V)")
- Adds a dedicated QuickSnap section with an activation button.

Shortcuts and Preferences

layout.prop(preferences, "hotkey_key_str", text="Pie Menu Shortcut")
layout.operator("DAMTools.capture_hotkey", text="Configure Pie Menu Shortcut")
- Allows viewing and configuring shortcuts from the panel.

Registration of Classes

classes = (
    DAMTools_PT_MainPanel,
    # ... other UI classes
)
- List of classes to register in Blender.


Key Code Snippets

class DAMTools_PT_MainPanel(Panel):
    def draw(self, context):
        layout = self.layout
        # ...

QuickSnap Button on the Panel

box_quicksnap.operator("object.quicksnap", text="Activate QuickSnap (Ctrl+Shift+V)")

Suggested Images

  • PLACE IMAGE OF ui.py SOURCE CODE IN THE EDITOR HERE
  • PLACE IMAGE OF THE DAMTools PANEL IN BLENDER'S N-PANEL
  • PLACE DIAGRAM OF THE SECTION ORGANIZATION IN THE PANEL

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