Skip to content

PLUGIN: Group OPs by purpose (Logical Grouping/Separation of Concerns) #19

Description

@Danweel

This is entirely for people coming to the the bpy from outside. Unfortunately it might mess with Fred if he's very used to the order.

Imports & Constants: import bpy, mybrushsize, myshadowsize.

Helper Functions: Small functions that do math or data lookup (e.g., find_layer_by_keyword, set_brush_size). These are pure logic, no bpy.ops calls ideally.

Operator Classes: The bpy.types.Operator classes.

Menu Registration: The register() and unregister() functions at the very bottom.

Blender Add-on convention works like this, so we should stick to that:

  1. Metadata
bl_info = {...}
  1. Imports
import bpy
  1. Constants
MYBRUSHSIZE = 13
  1. Helper functions (pure logic)
def find_layer(context, keyword):
    etc
  1. Operator classes
class MyOperator(bpy.types.Operator):
    etc
  1. Panel/Menu classes
class MyPanel(bpy.types.Panel):
    etc
  1. Registration
def register():
    bpy.utils.register_class(MyOperator)
    etc
def unregister():
    bpy.utils.unregister_class(MyOperator)
    etc
  1. Entry point
if __name__ == "__main__":
    register()

See #18
https://developer.blender.org/docs/handbook/extensions/addon_guidelines/
https://jlampel.github.io/blender_add-on_guidelines/06_code-structure.html

This will probably look like:

Imports
Constants (Brush names, Layer keywords, Material names)
Helper Functions (The "Tools")

    _find_layer(...)
    _ensure_mode(...)
    _setup_drawing_session(...)
    _apply_noise_step(...)
    _apply_thickness(...)

Operator Classes (The "Recipes")

    SimpleOperatorHIGHLIGHTS3 (Calls helpers)
    SimpleOperatorFRAMES1 (Calls helpers)
    SimpleOperatorOP8 (Calls helpers)
    ...

Registration (register(), unregister())

=investigate=

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C issueC-class issues don't explicitly prevent actions from being performed.SpicyHigh severity issues that affect use within the scope of its class.more info neededMore information surrounding the circumstances of issue or environment is needed

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions