3.5 KiB
3.5 KiB
GUI Blender Integration Plan
Goal
Add a checkbox and input fields to the GUI (gui/main_window.py) to enable/disable Blender script execution and specify the .blend file paths, defaulting to config.py values. Integrate this control into the processing logic (gui/processing_handler.py).
Proposed Plan
-
Modify
gui/main_window.py:- Add a
QCheckBox(e.g.,self.blender_integration_checkbox) to the processing panel layout. - Add two pairs of
QLineEditwidgets andQPushButtonbrowse buttons for the nodegroup.blendpath (self.nodegroup_blend_path_input,self.browse_nodegroup_blend_button) and the materials.blendpath (self.materials_blend_path_input,self.browse_materials_blend_button). - Initialize the text of the
QLineEditwidgets by reading theDEFAULT_NODEGROUP_BLEND_PATHandDEFAULT_MATERIALS_BLEND_PATHvalues fromconfig.pywhen the GUI starts. - Connect signals from the browse buttons to new methods that open a
QFileDialogto select.blendfiles and update the corresponding input fields. - Modify the slot connected to the "Start Processing" button to:
- Read the checked state of
self.blender_integration_checkbox. - Read the text from
self.nodegroup_blend_path_inputandself.materials_blend_path_input. - Pass these three pieces of information (checkbox state, nodegroup path, materials path) to the
ProcessingHandlerwhen initiating the processing task.
- Read the checked state of
- Add a
-
Modify
gui/processing_handler.py:- Add parameters to the method that starts the processing (likely
start_processing) to accept the Blender integration flag (boolean), the nodegroup.blendpath (string), and the materials.blendpath (string). - Implement the logic for finding the Blender executable (reading
BLENDER_EXECUTABLE_PATHfromconfig.pyor checking PATH) withinprocessing_handler.py. - Implement the logic for executing the Blender scripts using
subprocess.runwithinprocessing_handler.py. This logic should be similar to therun_blender_scriptfunction added tomain.pyin the previous step. - Ensure this Blender script execution logic is conditional based on the received integration flag and runs after the main asset processing (handled by the worker pool) is complete.
- Add parameters to the method that starts the processing (likely
Execution Flow Diagram (GUI)
graph TD
A[GUI: User Clicks Start Processing] --> B{Blender Integration Checkbox Checked?};
B -- Yes --> C[Get Blend File Paths from Input Fields];
C --> D[Pass Paths and Flag to ProcessingHandler];
D --> E[ProcessingHandler: Start Asset Processing (Worker Pool)];
E --> F[ProcessingHandler: Asset Processing Complete];
F --> G{Blender Integration Flag True?};
G -- Yes --> H[ProcessingHandler: Find Blender Executable];
H --> I{Blender Executable Found?};
I -- Yes --> J{Nodegroup Blend Path Valid?};
J -- Yes --> K[ProcessingHandler: Run Nodegroup Script in Blender];
K --> L{Script Successful?};
L -- Yes --> M{Materials Blend Path Valid?};
L -- No --> N[ProcessingHandler: Report Nodegroup Error];
N --> M;
M -- Yes --> O[ProcessingHandler: Run Materials Script in Blender];
O --> P{Script Successful?};
P -- Yes --> Q[ProcessingHandler: Report Completion];
P -- No --> R[ProcessingHandler: Report Materials Error];
R --> Q;
M -- No --> Q;
J -- No --> M[Skip Nodegroup Script];
I -- No --> Q[Skip Blender Scripts];
G -- No --> Q;
B -- No --> E;