init.py - Technical Documentation¶
PLACE IMAGE OF init.py SOURCE CODE IN THE EDITOR HERE
The __init__.py
file is the core of DAMTools. It defines the addon information, imports and registers all modules, operators, panels, and preferences, and manages QuickSnap integration and global shortcut configuration.
Index¶
- General Purpose
- File Structure
- Key Blocks and Explanation
- bl_info and Metadata
- Module Import
- QuickSnap Integration
- Preferences Definition
- Registration and Unregistration
- Key Code Snippets
- Suggested Images
General Purpose¶
- It is the entry point of the DAMTools addon.
- Defines the metadata for Blender (
bl_info
). - Imports and registers all modules and tools.
- Integrates QuickSnap functionality.
- Manages global preferences and shortcuts.
File Structure¶
- bl_info: Addon metadata (name, author, version, description, etc).
- Module Import: Imports
properties
,operators
,ui
,menu
, and QuickSnap. - QuickSnap Integration: Imports QuickSnap classes and menus, handles import errors.
- Preferences Definition:
DAMToolsPreferences
class with properties for shortcuts and global options. - Shortcut Capture Operators: Allows configuring shortcuts from preferences.
- Registration and Unregistration:
register()
andunregister()
functions to register all components.
Key Blocks and Explanation¶
bl_info and Metadata¶
bl_info = {
"name": "DAMTools",
"author": "NDSynrg",
"version": (1, 1, 0),
"blender": (3, 0, 0),
"location": "View3D > Sidebar (N Panel) > DAMTools | Pie Menu (configurable)",
"description": "Import/Export, align, join, rename by X, organize by X (Configurable Panel and Pie Menu).",
"warning": "Overrides keyboard shortcuts configured for the Pie Menu.",
"doc_url": "",
"category": "Import-Export",
}
Module Import¶
- Imports the addon's main modules.QuickSnap Integration¶
try:
from .quicksnap.quicksnap import QuickVertexSnapOperator, QuickVertexSnapPreference, ...
print("DAMTools: QuickSnap import successful.")
except ImportError as e:
print(f"DAMTools: Error importing QuickSnap: {e}")
# Define placeholder classes to prevent failures
Preferences Definition¶
class DAMToolsPreferences(AddonPreferences):
bl_idname = __name__
# Properties for global shortcuts and options
hotkey_key_str: StringProperty(...)
# ...
Registration and Unregistration¶
def register():
# Registers all modules, operators, panels, and preferences
...
def unregister():
# Unregisters all components
...
Key Code Snippets¶
Custom Shortcut Capture¶
class DAMTOOLS_OT_CaptureHotkey(Operator):
bl_idname = "damtools.capture_hotkey"
# ...
def modal(self, context, event):
# Captures the key combination and saves it in preferences
Preferences and Shortcut Registration¶
class DAMToolsPreferences(AddonPreferences):
bl_idname = __name__
# Properties for global shortcuts and options
Suggested Images¶
- PLACE IMAGE OF init.py SOURCE CODE IN THE EDITOR HERE
- PLACE DIAGRAM OF DEPENDENCIES BETWEEN MODULES
- PLACE IMAGE OF THE ADDON PREFERENCES IN BLENDER
To see the integration with each tool and menu, consult the documentation for the corresponding modules in the [DOCUMENTATION] folder.