[GH-ISSUE #3] feat: add progressbar for expode progress #2

Closed
opened 2026-10-14 09:52:32 +00:00 by allankoech · 5 comments
Owner

Originally created by @allankoechke on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/issues/3

Originally assigned to: @allankoechke on GitHub.

The C# sample had a progressbar showing the extent of the explode progress and we did not add it to our python UI. Add it and note that, it only shows when explode begins and is hidden thereafter.


Research Findings

Summary

The C# version has a full progress panel (m_pnlProgressPanel) with a ProgressBar, node info labels, and an escape-to-cancel label. It starts hidden and becomes visible only during the explode operation. The Python version (Python/explode_geometry.py and its Bundle2 copy) has no progress bar at all. Adding one requires UI changes in Ui_Form.setupUi(), and progress-update logic threaded through the do_explode() method and the two conversion functions.

Key Discoveries

  • C# progress panel is defined in Source/XAML/ExplodeGeomUserControl1.xaml:29-39 as a hidden Grid (m_pnlProgressPanel) containing: a ProgressBar (m_progBar), labels for "Processing Node: [name]", "Node: X of Y", and "Please press Escape to cancel..."
  • C# progress logic lives in two places:
    • Source/XAML/ExplodeGeomUserControl1.xaml.cs:229-244 -- PB_ProgressCurrNum / PB_ProgressMaxNum properties set bar value/maximum
    • Source/XAML/ExplodeGeomUserControl1.xaml.cs:251,320 -- panel shown at explode start (Visibility.Visible), hidden after completion (Visibility.Hidden)
  • Per-face progress updates happen inside ADNUtilities.cs:
    • Source/ADNUtilities.cs:277-295 -- ConvertToTriangleFaces sets max to nNumFaces, increments per face
    • Source/ADNUtilities.cs:433-449 -- ConvertToPolygonFaces sets max to nNumFaces, increments per face
  • Python UI is built programmatically in Ui_Form.setupUi() (Python/explode_geometry.py:21-107) using PySide6/QtWidgets -- no .ui file is used at runtime
  • Two identical Python files must be updated: Python/explode_geometry.py and Bundle2/Contents/python/explode_geometry.py
  • The .ui file at Python/assets/explode_geometry.ui is the legacy PySide1 designer file and is not loaded at runtime -- the current code builds UI inline

Detailed Findings

C# Progress Bar Implementation (Reference)

XAML layout (Source/XAML/ExplodeGeomUserControl1.xaml:29-39):

<Grid x:Name="m_pnlProgressPanel" Visibility="Hidden">
    <ProgressBar Name="m_progBar" Height="27" Width="378" />
    <Label Name="m_lblLabelProNode" Content="Processing Node:" />
    <Label Name="m_lblNodeName" Content="Node Name" />
    <Label Name="m_lblLabelNode" Content="Node:" />
    <Label Name="m_lblCurrNode" Content="num" />
    <Label Name="m_lblLabelOf" Content="of" />
    <Label Name="m_lblTotNode" Content="tot" />
    <Label Name="m_lblLabelEscape" Content="Please press Escape to cancel..." />
</Grid>

Progress flow (Source/XAML/ExplodeGeomUserControl1.xaml.cs:246-324):

  1. m_btnExplodeIt_Click: shows m_pnlProgressPanel (line 251)
  2. Sets m_lblTotNode to total selected nodes (line 274)
  3. Per-node: updates m_lblNodeName and m_lblCurrNode (lines 279-280)
  4. Calls ADN_Utility.ConvertToTriangleFaces/ConvertToPolygonFaces which update PB_ProgressCurrNum per face
  5. After all processing: hides m_pnlProgressPanel (line 320) and clears the control (line 321)

Per-face updates (Source/ADNUtilities.cs:277-295):

  • Before face loop: m_ctrlProgress.PB_ProgressMaxNum = nNumFaces
  • Inside face loop: m_ctrlProgress.PB_ProgressCurrNum = ++count

Python Code That Needs Changes

Python/explode_geometry.py (main file, also duplicated in Bundle2/Contents/python/explode_geometry.py):

  1. Ui_Form.setupUi() (lines 21-107): Add progress bar widgets between the explode button and the end of the layout
  2. Form.do_explode() (lines 147-198): Show/hide panel, update labels, pass callback to conversion functions
  3. convert_to_triangle_faces() (lines 216-238): Accept and call progress callback per face
  4. convert_to_mnmesh_faces() (lines 241-261): Accept and call progress callback per face

Files Requiring Changes

File Lines Change
Python/explode_geometry.py 86-104 Add QProgressBar, progress info labels, and container widget to setupUi()
Python/explode_geometry.py 109-123 Add retranslateUi text for new progress labels
Python/explode_geometry.py 147-198 In do_explode(): show/hide progress panel, update labels, pass callback
Python/explode_geometry.py 216-238 In convert_to_triangle_faces(): add progress callback, call per face
Python/explode_geometry.py 241-261 In convert_to_mnmesh_faces(): add progress callback, call per face
Bundle2/Contents/python/explode_geometry.py (same) Mirror all changes from Python/explode_geometry.py

Implementation Notes

  • Use QProgressBar from PySide6.QtWidgets
  • The progress container should start with .setVisible(False) and be set to .setVisible(True) when explode begins
  • Call QApplication.processEvents() after each progress bar update to prevent UI freezing
  • Conversion functions should accept an optional on_progress=None callback so they remain callable without a UI context
  • Both Python files are identical and both must be updated

Add Explode Progress Bar Implementation Plan

Overview

Port the C# progress panel (m_pnlProgressPanel) to the Python UI. A hidden progress container appears when the Explode button is clicked, updates a QProgressBar per-face as each node is processed, and is hidden again before the dialog closes. Both Python/explode_geometry.py and its identical copy Bundle2/Contents/python/explode_geometry.py must receive the same changes.

Current State Analysis

Key Discoveries:

  • Ui_Form.setupUi() (Python/explode_geometry.py:21-107) builds the entire UI inline -- there is no .ui file loaded at runtime
  • The explode button is the last widget added to mainLayout (line 104) -- the progress panel goes after it
  • Form.do_explode() (lines 147-198) runs the conversion loops synchronously on the main thread; QApplication.processEvents() is the only way to keep the UI alive during processing
  • convert_to_triangle_faces() (lines 216-238) iterates faces 1 to N in forward order
  • convert_to_mnmesh_faces() (lines 241-261) iterates faces N to 1 in reverse order -- a forward counter must be tracked separately for correct progress display
  • Both Python/explode_geometry.py and Bundle2/Contents/python/explode_geometry.py are byte-for-byte identical and must both be updated

Desired End State

When the user clicks Explode:

  1. A progress panel becomes visible below the Explode button
  2. The panel shows a QProgressBar filling from 0 to 100% as faces are processed
  3. Labels show "Processing Node: <name>" and "Node: X of Y" (where X/Y are the current/total selected objects)
  4. After all processing completes, the panel is hidden before the dialog closes
  5. The UI remains responsive (not frozen) throughout

Verification: Run the script in 3ds Max, select a mesh with many faces, click Explode -- the progress bar should visibly advance and the labels should update.

What We Are NOT Doing

  • Escape-to-cancel: The issue only asks for the progress bar; cancel support is a follow-up
  • Changing the .ui designer file at Python/assets/explode_geometry.ui -- it is not loaded at runtime
  • Refactoring applySettings(), _GCProtector, or any unrelated code

Implementation Approach

  1. Add self.progress_panel (a QWidget with QVBoxLayout, initially hidden) to Ui_Form.setupUi() immediately after the explode button, with a QProgressBar and two info rows
  2. Update retranslateUi() with the static label text
  3. In Form.do_explode(), show the panel before the loops, set the "total nodes" label, update per-node labels each iteration, and hide the panel after all processing
  4. Thread a progress callback through convert_to_triangle_faces() and convert_to_mnmesh_faces() as an optional on_progress=None parameter that the Form passes as a lambda updating self.progress_bar
  5. Mirror all changes to Bundle2/Contents/python/explode_geometry.py

IMPORTANT: Checkboxes are for implementation steps only. Steps requiring manual human verification are in the "Manual Testing Steps" section below.


TASK 1: Add Progress Panel Widgets to Ui_Form [HIGH PRIORITY]

Status: NOT STARTED
Milestone: Progress panel widget tree exists in setupUi(), is initially hidden, and all labels have translated text

  • After mainLayout.addWidget(self.explode_button) (line 104), create self.progress_panel = QtWidgets.QWidget(Form) with self.progress_panel.setObjectName("progress_panel")
  • Create progressLayout = QtWidgets.QVBoxLayout(self.progress_panel) with appropriate margins/spacing
  • Add self.progress_bar = QtWidgets.QProgressBar(self.progress_panel) with setObjectName("progress_bar"), and set setMinimum(0), setMaximum(100), setValue(0)
  • Add a QHBoxLayout node-name row containing: a fixed QLabel ("Processing Node:") and self.lbl_node_name = QtWidgets.QLabel(self.progress_panel) with setObjectName("lbl_node_name")
  • Add a QHBoxLayout counter row containing: a fixed QLabel ("Node:"), self.lbl_curr_node = QtWidgets.QLabel(self.progress_panel) (setObjectName("lbl_curr_node")), a fixed QLabel ("of"), and self.lbl_tot_node = QtWidgets.QLabel(self.progress_panel) (setObjectName("lbl_tot_node"))
  • Call self.progress_panel.setVisible(False) to hide it initially
  • Add mainLayout.addWidget(self.progress_panel) after the explode button widget
  • In retranslateUi(), add setText calls for the two fixed-text labels ("Processing Node:" and "Node:" / "of") using QCoreApplication.translate

Validation: Open the dialog in Max -- the progress panel must not be visible at startup. Confirm progress_panel, progress_bar, lbl_node_name, lbl_curr_node, and lbl_tot_node exist as attributes on the Ui_Form instance.

Requirements from spec:

  • Progress panel is hidden by default and only shown during explode
  • Contains a progress bar and info labels matching the C# reference

Files to Modify:

  • Python/explode_geometry.py -- Ui_Form.setupUi() (after line 104) and Ui_Form.retranslateUi() (after line 123)

TASK 2: Wire Progress Show/Hide and Node Labels in Form.do_explode() [HIGH PRIORITY]

Status: NOT STARTED
Milestone: Progress panel appears when Explode is clicked, node name and counter labels update per object, panel hides before dialog closes

  • At the start of the else branch in do_explode() (line 170, just before with pymxs.undo), add self.progress_panel.setVisible(True) and QtWidgets.QApplication.processEvents()
  • Before each for loop (TriMesh at line 174 and MNMesh at line 186), set self.lbl_tot_node.setText(str(len(transformation_set)))
  • Inside the TriMesh for loop (line 174), after the existing print(...), add: self.lbl_node_name.setText(n.name), self.lbl_curr_node.setText(str(i)), QtWidgets.QApplication.processEvents()
  • Inside the MNMesh for loop (line 186), after the existing print(...), add: self.lbl_node_name.setText(node.name), self.lbl_curr_node.setText(str(i)), QtWidgets.QApplication.processEvents()
  • Define a progress callback for TriMesh: a local function _prog(cur, tot) that calls self.progress_bar.setValue(int(cur * 100 / tot) if tot else 0) and QtWidgets.QApplication.processEvents(), then pass it as on_progress=_prog to convert_to_triangle_faces() (line 176)
  • Define an equivalent _prog callback for MNMesh and pass it as on_progress=_prog to convert_to_mnmesh_faces() (line 188)
  • After rt.redrawViews() (line 196) and before self.close() (line 198), add self.progress_panel.setVisible(False) and self.progress_bar.setValue(0)

Validation: During explode the panel is visible and "Node: 1 of 3" style text updates for each object. After completion the panel disappears before the dialog closes.

Requirements from spec:

  • Panel shows only when explode begins and is hidden thereafter
  • Node name and node counter labels update per object

Files to Modify:

  • Python/explode_geometry.py -- Form.do_explode() (lines 147-198)

TASK 3: Add on_progress Callback to Conversion Functions [HIGH PRIORITY]

Status: NOT STARTED
Milestone: Both conversion functions accept an optional on_progress callback and call it per face, keeping UI responsive

  • In convert_to_triangle_faces() signature (line 216), add on_progress=None as the last parameter
  • In convert_to_triangle_faces(), before the face loop (after line 221), add: if on_progress: on_progress(0, num_faces)
  • Inside the face loop body of convert_to_triangle_faces() (after the applySettings call at line 237), add: if on_progress: on_progress(face_idx, num_faces)
  • In convert_to_mnmesh_faces() signature (line 241), add on_progress=None as the last parameter
  • In convert_to_mnmesh_faces(), before the face loop (after line 245), add: if on_progress: on_progress(0, num_faces) and introduce _processed = 0
  • Inside the face loop body of convert_to_mnmesh_faces() (after the applySettings call at line 260), add: _processed += 1 then if on_progress: on_progress(_processed, num_faces) (note: the loop goes N to 1 in reverse so _processed provides the forward count)

Validation: Both functions can be called without on_progress (default None path must not error). When called with a callback, it is invoked once before the loop (at 0) and once per face.

Requirements from spec:

  • Per-face progress updates mirroring ADNUtilities.cs:277-295 and ADNUtilities.cs:433-449
  • Callback is optional so functions remain usable without a UI context

Files to Modify:

  • Python/explode_geometry.py -- convert_to_triangle_faces() (lines 216-238) and convert_to_mnmesh_faces() (lines 241-261)

TASK 4: Mirror All Changes to Bundle2 [HIGH PRIORITY]

Status: NOT STARTED
Milestone: Bundle2/Contents/python/explode_geometry.py is identical to Python/explode_geometry.py after all changes

  • Apply every change from Tasks 1-3 identically to Bundle2/Contents/python/explode_geometry.py
  • Verify the two files are identical after applying changes by running diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py -- it should produce no output

Validation: diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py returns exit code 0 with no output.

Requirements from spec:

  • Both deployment paths must include the same progress bar functionality

Files to Modify:

  • Bundle2/Contents/python/explode_geometry.py -- all sections matching Tasks 1-3

Testing Strategy

Unit Tests:

  • No automated test framework exists in this repo -- validation is manual in 3ds Max

Integration Tests:

  • Load the script in 3ds Max via both the standalone Python/ path and the Bundle2 package path
  • Verify both load without import errors

Manual Testing Steps:

  1. Open 3ds Max and run the script from both Python/ and Bundle2/ paths
  2. Open the Explode Geometry dialog -- confirm the progress panel is not visible at startup
  3. Select a mesh object with many faces (e.g., a sphere with 100+ faces) and click Explode
  4. Confirm the progress panel becomes visible immediately, the progress bar advances per face, and "Processing Node: <name>" and "Node: 1 of 1" labels show correctly
  5. After explode completes, confirm the dialog closes and the progress panel was hidden before close
  6. Repeat with multiple selected objects and verify the node counter increments (e.g., "Node: 2 of 3")
  7. Test both TriMesh and MNMesh modes

Performance Considerations

  • QApplication.processEvents() is called once per face -- this is intentional to keep the UI alive but adds slight overhead. For meshes with thousands of faces this is acceptable; it matches the C# pattern exactly.
  • No threading is introduced -- the operation remains synchronous. This is out of scope per the issue.
Originally created by @allankoechke on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/issues/3 Originally assigned to: @allankoechke on GitHub. The C# sample had a progressbar showing the extent of the explode progress and we did not add it to our python UI. Add it and note that, it only shows when explode begins and is hidden thereafter. --- <details> <summary><h2>Research Findings</h2></summary> ### Summary The C# version has a full progress panel (`m_pnlProgressPanel`) with a `ProgressBar`, node info labels, and an escape-to-cancel label. It starts hidden and becomes visible only during the explode operation. The Python version (`Python/explode_geometry.py` and its Bundle2 copy) has no progress bar at all. Adding one requires UI changes in `Ui_Form.setupUi()`, and progress-update logic threaded through the `do_explode()` method and the two conversion functions. ### Key Discoveries - **C# progress panel** is defined in `Source/XAML/ExplodeGeomUserControl1.xaml:29-39` as a hidden Grid (`m_pnlProgressPanel`) containing: a `ProgressBar` (`m_progBar`), labels for "Processing Node: [name]", "Node: X of Y", and "Please press Escape to cancel..." - **C# progress logic** lives in two places: - `Source/XAML/ExplodeGeomUserControl1.xaml.cs:229-244` -- `PB_ProgressCurrNum` / `PB_ProgressMaxNum` properties set bar value/maximum - `Source/XAML/ExplodeGeomUserControl1.xaml.cs:251,320` -- panel shown at explode start (`Visibility.Visible`), hidden after completion (`Visibility.Hidden`) - **Per-face progress updates** happen inside `ADNUtilities.cs`: - `Source/ADNUtilities.cs:277-295` -- `ConvertToTriangleFaces` sets max to `nNumFaces`, increments per face - `Source/ADNUtilities.cs:433-449` -- `ConvertToPolygonFaces` sets max to `nNumFaces`, increments per face - **Python UI** is built programmatically in `Ui_Form.setupUi()` (`Python/explode_geometry.py:21-107`) using PySide6/QtWidgets -- no `.ui` file is used at runtime - **Two identical Python files** must be updated: `Python/explode_geometry.py` and `Bundle2/Contents/python/explode_geometry.py` - The `.ui` file at `Python/assets/explode_geometry.ui` is the legacy PySide1 designer file and is **not loaded at runtime** -- the current code builds UI inline ### Detailed Findings #### C# Progress Bar Implementation (Reference) **XAML layout** (`Source/XAML/ExplodeGeomUserControl1.xaml:29-39`): ```xml <Grid x:Name="m_pnlProgressPanel" Visibility="Hidden"> <ProgressBar Name="m_progBar" Height="27" Width="378" /> <Label Name="m_lblLabelProNode" Content="Processing Node:" /> <Label Name="m_lblNodeName" Content="Node Name" /> <Label Name="m_lblLabelNode" Content="Node:" /> <Label Name="m_lblCurrNode" Content="num" /> <Label Name="m_lblLabelOf" Content="of" /> <Label Name="m_lblTotNode" Content="tot" /> <Label Name="m_lblLabelEscape" Content="Please press Escape to cancel..." /> </Grid> ``` **Progress flow** (`Source/XAML/ExplodeGeomUserControl1.xaml.cs:246-324`): 1. `m_btnExplodeIt_Click`: shows `m_pnlProgressPanel` (line 251) 2. Sets `m_lblTotNode` to total selected nodes (line 274) 3. Per-node: updates `m_lblNodeName` and `m_lblCurrNode` (lines 279-280) 4. Calls `ADN_Utility.ConvertToTriangleFaces/ConvertToPolygonFaces` which update `PB_ProgressCurrNum` per face 5. After all processing: hides `m_pnlProgressPanel` (line 320) and clears the control (line 321) **Per-face updates** (`Source/ADNUtilities.cs:277-295`): - Before face loop: `m_ctrlProgress.PB_ProgressMaxNum = nNumFaces` - Inside face loop: `m_ctrlProgress.PB_ProgressCurrNum = ++count` #### Python Code That Needs Changes **`Python/explode_geometry.py`** (main file, also duplicated in `Bundle2/Contents/python/explode_geometry.py`): 1. **`Ui_Form.setupUi()`** (lines 21-107): Add progress bar widgets between the explode button and the end of the layout 2. **`Form.do_explode()`** (lines 147-198): Show/hide panel, update labels, pass callback to conversion functions 3. **`convert_to_triangle_faces()`** (lines 216-238): Accept and call progress callback per face 4. **`convert_to_mnmesh_faces()`** (lines 241-261): Accept and call progress callback per face ### Files Requiring Changes | File | Lines | Change | |------|-------|--------| | `Python/explode_geometry.py` | 86-104 | Add `QProgressBar`, progress info labels, and container widget to `setupUi()` | | `Python/explode_geometry.py` | 109-123 | Add `retranslateUi` text for new progress labels | | `Python/explode_geometry.py` | 147-198 | In `do_explode()`: show/hide progress panel, update labels, pass callback | | `Python/explode_geometry.py` | 216-238 | In `convert_to_triangle_faces()`: add progress callback, call per face | | `Python/explode_geometry.py` | 241-261 | In `convert_to_mnmesh_faces()`: add progress callback, call per face | | `Bundle2/Contents/python/explode_geometry.py` | (same) | Mirror all changes from `Python/explode_geometry.py` | ### Implementation Notes - Use `QProgressBar` from PySide6.QtWidgets - The progress container should start with `.setVisible(False)` and be set to `.setVisible(True)` when explode begins - Call `QApplication.processEvents()` after each progress bar update to prevent UI freezing - Conversion functions should accept an optional `on_progress=None` callback so they remain callable without a UI context - Both Python files are identical and both must be updated </details> --- <!-- kiln:plan --> # Add Explode Progress Bar Implementation Plan ## Overview Port the C# progress panel (`m_pnlProgressPanel`) to the Python UI. A hidden progress container appears when the Explode button is clicked, updates a `QProgressBar` per-face as each node is processed, and is hidden again before the dialog closes. Both `Python/explode_geometry.py` and its identical copy `Bundle2/Contents/python/explode_geometry.py` must receive the same changes. ## Current State Analysis ### Key Discoveries: - `Ui_Form.setupUi()` (`Python/explode_geometry.py:21-107`) builds the entire UI inline -- there is no `.ui` file loaded at runtime - The explode button is the last widget added to `mainLayout` (`line 104`) -- the progress panel goes after it - `Form.do_explode()` (`lines 147-198`) runs the conversion loops synchronously on the main thread; `QApplication.processEvents()` is the only way to keep the UI alive during processing - `convert_to_triangle_faces()` (`lines 216-238`) iterates faces 1 to N in forward order - `convert_to_mnmesh_faces()` (`lines 241-261`) iterates faces N to 1 in **reverse** order -- a forward counter must be tracked separately for correct progress display - Both `Python/explode_geometry.py` and `Bundle2/Contents/python/explode_geometry.py` are byte-for-byte identical and must both be updated ## Desired End State When the user clicks Explode: 1. A progress panel becomes visible below the Explode button 2. The panel shows a `QProgressBar` filling from 0 to 100% as faces are processed 3. Labels show "Processing Node: `<name>`" and "Node: `X` of `Y`" (where X/Y are the current/total selected objects) 4. After all processing completes, the panel is hidden before the dialog closes 5. The UI remains responsive (not frozen) throughout Verification: Run the script in 3ds Max, select a mesh with many faces, click Explode -- the progress bar should visibly advance and the labels should update. ## What We Are NOT Doing - **Escape-to-cancel**: The issue only asks for the progress bar; cancel support is a follow-up - **Changing the `.ui` designer file** at `Python/assets/explode_geometry.ui` -- it is not loaded at runtime - **Refactoring** `applySettings()`, `_GCProtector`, or any unrelated code ## Implementation Approach 1. Add `self.progress_panel` (a `QWidget` with `QVBoxLayout`, initially hidden) to `Ui_Form.setupUi()` immediately after the explode button, with a `QProgressBar` and two info rows 2. Update `retranslateUi()` with the static label text 3. In `Form.do_explode()`, show the panel before the loops, set the "total nodes" label, update per-node labels each iteration, and hide the panel after all processing 4. Thread a progress callback through `convert_to_triangle_faces()` and `convert_to_mnmesh_faces()` as an optional `on_progress=None` parameter that the `Form` passes as a lambda updating `self.progress_bar` 5. Mirror all changes to `Bundle2/Contents/python/explode_geometry.py` --- **IMPORTANT: Checkboxes are for implementation steps only.** Steps requiring manual human verification are in the "Manual Testing Steps" section below. --- ### TASK 1: Add Progress Panel Widgets to `Ui_Form` [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** Progress panel widget tree exists in `setupUi()`, is initially hidden, and all labels have translated text - [ ] After `mainLayout.addWidget(self.explode_button)` (line 104), create `self.progress_panel = QtWidgets.QWidget(Form)` with `self.progress_panel.setObjectName("progress_panel")` - [ ] Create `progressLayout = QtWidgets.QVBoxLayout(self.progress_panel)` with appropriate margins/spacing - [ ] Add `self.progress_bar = QtWidgets.QProgressBar(self.progress_panel)` with `setObjectName("progress_bar")`, and set `setMinimum(0)`, `setMaximum(100)`, `setValue(0)` - [ ] Add a `QHBoxLayout` node-name row containing: a fixed `QLabel` ("Processing Node:") and `self.lbl_node_name = QtWidgets.QLabel(self.progress_panel)` with `setObjectName("lbl_node_name")` - [ ] Add a `QHBoxLayout` counter row containing: a fixed `QLabel` ("Node:"), `self.lbl_curr_node = QtWidgets.QLabel(self.progress_panel)` (`setObjectName("lbl_curr_node")`), a fixed `QLabel` ("of"), and `self.lbl_tot_node = QtWidgets.QLabel(self.progress_panel)` (`setObjectName("lbl_tot_node")`) - [ ] Call `self.progress_panel.setVisible(False)` to hide it initially - [ ] Add `mainLayout.addWidget(self.progress_panel)` after the explode button widget - [ ] In `retranslateUi()`, add `setText` calls for the two fixed-text labels ("Processing Node:" and "Node:" / "of") using `QCoreApplication.translate` **Validation:** Open the dialog in Max -- the progress panel must not be visible at startup. Confirm `progress_panel`, `progress_bar`, `lbl_node_name`, `lbl_curr_node`, and `lbl_tot_node` exist as attributes on the `Ui_Form` instance. **Requirements from spec:** - Progress panel is hidden by default and only shown during explode - Contains a progress bar and info labels matching the C# reference **Files to Modify:** - `Python/explode_geometry.py` -- `Ui_Form.setupUi()` (after line 104) and `Ui_Form.retranslateUi()` (after line 123) --- ### TASK 2: Wire Progress Show/Hide and Node Labels in `Form.do_explode()` [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** Progress panel appears when Explode is clicked, node name and counter labels update per object, panel hides before dialog closes - [ ] At the start of the `else` branch in `do_explode()` (line 170, just before `with pymxs.undo`), add `self.progress_panel.setVisible(True)` and `QtWidgets.QApplication.processEvents()` - [ ] Before each `for` loop (TriMesh at line 174 and MNMesh at line 186), set `self.lbl_tot_node.setText(str(len(transformation_set)))` - [ ] Inside the TriMesh `for` loop (line 174), after the existing `print(...)`, add: `self.lbl_node_name.setText(n.name)`, `self.lbl_curr_node.setText(str(i))`, `QtWidgets.QApplication.processEvents()` - [ ] Inside the MNMesh `for` loop (line 186), after the existing `print(...)`, add: `self.lbl_node_name.setText(node.name)`, `self.lbl_curr_node.setText(str(i))`, `QtWidgets.QApplication.processEvents()` - [ ] Define a progress callback for TriMesh: a local function `_prog(cur, tot)` that calls `self.progress_bar.setValue(int(cur * 100 / tot) if tot else 0)` and `QtWidgets.QApplication.processEvents()`, then pass it as `on_progress=_prog` to `convert_to_triangle_faces()` (line 176) - [ ] Define an equivalent `_prog` callback for MNMesh and pass it as `on_progress=_prog` to `convert_to_mnmesh_faces()` (line 188) - [ ] After `rt.redrawViews()` (line 196) and before `self.close()` (line 198), add `self.progress_panel.setVisible(False)` and `self.progress_bar.setValue(0)` **Validation:** During explode the panel is visible and "Node: 1 of 3" style text updates for each object. After completion the panel disappears before the dialog closes. **Requirements from spec:** - Panel shows only when explode begins and is hidden thereafter - Node name and node counter labels update per object **Files to Modify:** - `Python/explode_geometry.py` -- `Form.do_explode()` (lines 147-198) --- ### TASK 3: Add `on_progress` Callback to Conversion Functions [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** Both conversion functions accept an optional `on_progress` callback and call it per face, keeping UI responsive - [ ] In `convert_to_triangle_faces()` signature (line 216), add `on_progress=None` as the last parameter - [ ] In `convert_to_triangle_faces()`, before the face loop (after line 221), add: `if on_progress: on_progress(0, num_faces)` - [ ] Inside the face loop body of `convert_to_triangle_faces()` (after the `applySettings` call at line 237), add: `if on_progress: on_progress(face_idx, num_faces)` - [ ] In `convert_to_mnmesh_faces()` signature (line 241), add `on_progress=None` as the last parameter - [ ] In `convert_to_mnmesh_faces()`, before the face loop (after line 245), add: `if on_progress: on_progress(0, num_faces)` and introduce `_processed = 0` - [ ] Inside the face loop body of `convert_to_mnmesh_faces()` (after the `applySettings` call at line 260), add: `_processed += 1` then `if on_progress: on_progress(_processed, num_faces)` (note: the loop goes N to 1 in reverse so `_processed` provides the forward count) **Validation:** Both functions can be called without `on_progress` (default `None` path must not error). When called with a callback, it is invoked once before the loop (at 0) and once per face. **Requirements from spec:** - Per-face progress updates mirroring `ADNUtilities.cs:277-295` and `ADNUtilities.cs:433-449` - Callback is optional so functions remain usable without a UI context **Files to Modify:** - `Python/explode_geometry.py` -- `convert_to_triangle_faces()` (lines 216-238) and `convert_to_mnmesh_faces()` (lines 241-261) --- ### TASK 4: Mirror All Changes to Bundle2 [HIGH PRIORITY] **Status:** NOT STARTED **Milestone:** `Bundle2/Contents/python/explode_geometry.py` is identical to `Python/explode_geometry.py` after all changes - [ ] Apply every change from Tasks 1-3 identically to `Bundle2/Contents/python/explode_geometry.py` - [ ] Verify the two files are identical after applying changes by running `diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py` -- it should produce no output **Validation:** `diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py` returns exit code 0 with no output. **Requirements from spec:** - Both deployment paths must include the same progress bar functionality **Files to Modify:** - `Bundle2/Contents/python/explode_geometry.py` -- all sections matching Tasks 1-3 --- ## Testing Strategy ### Unit Tests: - No automated test framework exists in this repo -- validation is manual in 3ds Max ### Integration Tests: - Load the script in 3ds Max via both the standalone `Python/` path and the Bundle2 package path - Verify both load without import errors ### Manual Testing Steps: 1. Open 3ds Max and run the script from both `Python/` and `Bundle2/` paths 2. Open the Explode Geometry dialog -- confirm the progress panel is **not visible** at startup 3. Select a mesh object with many faces (e.g., a sphere with 100+ faces) and click Explode 4. Confirm the progress panel becomes visible immediately, the progress bar advances per face, and "Processing Node: `<name>`" and "Node: 1 of 1" labels show correctly 5. After explode completes, confirm the dialog closes and the progress panel was hidden before close 6. Repeat with multiple selected objects and verify the node counter increments (e.g., "Node: 2 of 3") 7. Test both TriMesh and MNMesh modes ## Performance Considerations - `QApplication.processEvents()` is called once per face -- this is intentional to keep the UI alive but adds slight overhead. For meshes with thousands of faces this is acceptable; it matches the C# pattern exactly. - No threading is introduced -- the operation remains synchronous. This is out of scope per the issue. <!-- /kiln:plan -->
allankoech added the
kiln
plan_ready
research_ready
pr_ready
cleaned_up
labels 2026-10-14 09:52:32 +00:00
Author
Owner

@allankoechke commented on GitHub (Jun 23, 2026):

Implementation complete! PR ready for review: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/pull/4

<!-- gh-comment-id:4781465433 --> @allankoechke commented on GitHub (Jun 23, 2026): <!-- kiln:log --> Implementation complete! PR ready for review: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/pull/4 <!-- /kiln:log -->
Author
Owner

@allankoechke commented on GitHub (Jun 24, 2026):

The progressbar and its controls should be above the explode button
Also, add a checkbox in the explode options that toggles showing debug messages. When checked, the logger pushes all messages to the maxscript listener, when unchecked, only warning and critical messages are let through from the logger. Use python logger lib

<!-- gh-comment-id:4787467903 --> @allankoechke commented on GitHub (Jun 24, 2026): The progressbar and its controls should be above the explode button Also, add a checkbox in the explode options that toggles showing debug messages. When checked, the logger pushes all messages to the maxscript listener, when unchecked, only warning and critical messages are let through from the logger. Use python logger lib
Author
Owner

@allankoechke commented on GitHub (Jun 24, 2026):

Implemented both requested changes in Python/explode_geometry.py and the mirrored Bundle2/Contents/python/explode_geometry.py:

1. Progress panel moved above the Explode button
The hidden progress_panel (progress bar + "Processing Node" / "Node X of Y" labels) is now added to the layout before the Explode button, so it renders above it. It still starts hidden and only shows during an explode.

2. Debug-message toggle using the logging lib

  • Added a "Show Debug Messages" checkbox to the Explode Options group.
  • Replaced all print(...) calls with a stdlib logging.Logger("ExplodeGeometry") whose StreamHandler writes to stdout (the MAXScript Listener).
  • On each explode, the level is set to DEBUG when the checkbox is checked (all messages pass through) and WARNING when unchecked (only warning/critical messages). Per-face/per-node info is logged at DEBUG; the "nothing selected" message is logger.error and the missing-detached-node case is logger.warning, so those still appear when debug is off.

Both files compile cleanly and remain byte-for-byte identical. Note: this branch is not yet merged, so the bundled .dll assemblies are unaffected — changes are Python-only.

<!-- gh-comment-id:4787514432 --> @allankoechke commented on GitHub (Jun 24, 2026): <!-- kiln:response --> Implemented both requested changes in `Python/explode_geometry.py` and the mirrored `Bundle2/Contents/python/explode_geometry.py`: **1. Progress panel moved above the Explode button** The hidden `progress_panel` (progress bar + "Processing Node" / "Node X of Y" labels) is now added to the layout *before* the Explode button, so it renders above it. It still starts hidden and only shows during an explode. **2. Debug-message toggle using the `logging` lib** - Added a **"Show Debug Messages"** checkbox to the Explode Options group. - Replaced all `print(...)` calls with a stdlib `logging.Logger("ExplodeGeometry")` whose `StreamHandler` writes to stdout (the MAXScript Listener). - On each explode, the level is set to `DEBUG` when the checkbox is checked (all messages pass through) and `WARNING` when unchecked (only warning/critical messages). Per-face/per-node info is logged at `DEBUG`; the "nothing selected" message is `logger.error` and the missing-detached-node case is `logger.warning`, so those still appear when debug is off. Both files compile cleanly and remain byte-for-byte identical. Note: this branch is not yet merged, so the bundled `.dll` assemblies are unaffected — changes are Python-only. <!-- /kiln:response -->
Author
Owner

@allankoechke commented on GitHub (Jun 24, 2026):

If explode process succeed, lets print a message on maxscript listener with how long it took

<!-- gh-comment-id:4787734255 --> @allankoechke commented on GitHub (Jun 24, 2026): If explode process succeed, lets print a message on maxscript listener with how long it took
Author
Owner

@allankoechke commented on GitHub (Jun 24, 2026):

Added explode-duration reporting in Python/explode_geometry.py and the mirrored Bundle2/Contents/python/explode_geometry.py.

  • The elapsed time is captured with time.perf_counter() right before processing begins and measured again after redrawViews() on a successful run.
  • On success, the Listener shows: [ExplodeGeometry] Explode completed successfully in N.NN seconds.
  • This uses a direct print() rather than the logger so the completion summary always appears, regardless of the "Show Debug Messages" toggle. It only prints when the explode actually runs (i.e. when something is selected), so the failed/"nothing selected" path is unaffected.

Both files compile cleanly and remain byte-for-byte identical.

<!-- gh-comment-id:4787744614 --> @allankoechke commented on GitHub (Jun 24, 2026): <!-- kiln:response --> Added explode-duration reporting in `Python/explode_geometry.py` and the mirrored `Bundle2/Contents/python/explode_geometry.py`. - The elapsed time is captured with `time.perf_counter()` right before processing begins and measured again after `redrawViews()` on a successful run. - On success, the Listener shows: `[ExplodeGeometry] Explode completed successfully in N.NN seconds.` - This uses a direct `print()` rather than the logger so the completion summary always appears, regardless of the "Show Debug Messages" toggle. It only prints when the explode actually runs (i.e. when something is selected), so the failed/"nothing selected" path is unaffected. Both files compile cleanly and remain byte-for-byte identical. <!-- /kiln:response -->
allankoech added
kiln
plan_ready
cleaned_up
and removed
kiln
plan_ready
cleaned_up
labels 2026-10-21 17:01:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: allankoech/ADN-3dsMax-Explode-Geometry#2
No description provided.