{
    "sourceFile": "Project Notes/BLENDER_INTEGRATION_PLAN_v2.md",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 0,
            "patches": [
                {
                    "date": 1745261903310,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                }
            ],
            "date": 1745261903310,
            "name": "Commit-0",
            "content": "# Blender Integration Plan v2\r\n\r\n## Goal\r\n\r\nAdd an optional step to `main.py` to run `blenderscripts/create_nodegroups.py` and `blenderscripts/create_materials.py` on specified `.blend` files after asset processing is complete.\r\n\r\n## Proposed Plan\r\n\r\n1.  **Update `config.py`:**\r\n    *   Add two new optional configuration variables: `DEFAULT_NODEGROUP_BLEND_PATH` and `DEFAULT_MATERIALS_BLEND_PATH`. These will store the default paths to the Blender files.\r\n\r\n2.  **Update `main.py` Argument Parser:**\r\n    *   Add two new optional command-line arguments: `--nodegroup-blend` and `--materials-blend`.\r\n    *   These arguments will accept file paths to the respective `.blend` files.\r\n    *   If provided, these arguments will override the default paths specified in `config.py`.\r\n\r\n3.  **Update `blenderscripts/create_nodegroups.py` and `blenderscripts/create_materials.py`:**\r\n    *   Modify both scripts to accept the processed asset library root path (`PROCESSED_ASSET_LIBRARY_ROOT`) as a command-line argument. This will be passed to the script when executed by Blender using the `--` separator.\r\n    *   Update the scripts to read this path from `sys.argv` instead of using the hardcoded variable.\r\n\r\n4.  **Update `main.py` Execution Flow:**\r\n    *   After the main asset processing loop (`run_processing`) completes and the summary is reported, check if the `--nodegroup-blend` or `--materials-blend` arguments (or their fallbacks from `config.py`) were provided.\r\n    *   If a path for the nodegroup `.blend` file is available:\r\n        *   Construct a command to execute Blender in the background (`-b`), load the specified nodegroup `.blend` file, run the `create_nodegroups.py` script using `--python`, pass the processed asset root directory as an argument after `--`, and save the `.blend` file (`-S`).\r\n        *   Execute this command using the `execute_command` tool.\r\n    *   If a path for the materials `.blend` file is available:\r\n        *   Construct a similar command to execute Blender in the background, load the specified materials `.blend` file, run the `create_materials.py` script using `--python`, pass the processed asset root directory as an argument after `--`, and save the `.blend` file (`-S`).\r\n        *   Execute this command using the `execute_command` tool.\r\n    *   Include error handling for the execution of the Blender commands.\r\n\r\n## Execution Flow Diagram\r\n\r\n```mermaid\r\ngraph TD\r\n    A[Asset Processing Complete] --> B[Report Summary];\r\n    B --> C{Nodegroup Blend Path Specified?};\r\n    C -- Yes --> D[Get Nodegroup Blend Path (Arg or Config)];\r\n    D --> E[Construct Blender Command for Nodegroups];\r\n    E --> F[Execute Command: blender -b nodegroup.blend --python create_nodegroups.py -- <asset_root> -S];\r\n    F --> G{Command Successful?};\r\n    G -- Yes --> H{Materials Blend Path Specified?};\r\n    G -- No --> I[Log Nodegroup Error];\r\n    I --> H;\r\n    H -- Yes --> J[Get Materials Blend Path (Arg or Config)];\r\n    J --> K[Construct Blender Command for Materials];\r\n    K --> L[Execute Command: blender -b materials.blend --python create_materials.py -- <asset_root> -S];\r\n    L --> M{Command Successful?};\r\n    M -- Yes --> N[End main.py];\r\n    M -- No --> O[Log Materials Error];\r\n    O --> N;\r\n    H -- No --> N;\r\n    C -- No --> H;"
        }
    ]
}