mirror of
https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry.git
synced 2026-11-30 09:22:10 +00:00
[GH-ISSUE #3] feat: add progressbar for expode progress #2
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 aProgressBar, 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.pyand its Bundle2 copy) has no progress bar at all. Adding one requires UI changes inUi_Form.setupUi(), and progress-update logic threaded through thedo_explode()method and the two conversion functions.Key Discoveries
Source/XAML/ExplodeGeomUserControl1.xaml:29-39as a hidden Grid (m_pnlProgressPanel) containing: aProgressBar(m_progBar), labels for "Processing Node: [name]", "Node: X of Y", and "Please press Escape to cancel..."Source/XAML/ExplodeGeomUserControl1.xaml.cs:229-244--PB_ProgressCurrNum/PB_ProgressMaxNumproperties set bar value/maximumSource/XAML/ExplodeGeomUserControl1.xaml.cs:251,320-- panel shown at explode start (Visibility.Visible), hidden after completion (Visibility.Hidden)ADNUtilities.cs:Source/ADNUtilities.cs:277-295--ConvertToTriangleFacessets max tonNumFaces, increments per faceSource/ADNUtilities.cs:433-449--ConvertToPolygonFacessets max tonNumFaces, increments per faceUi_Form.setupUi()(Python/explode_geometry.py:21-107) using PySide6/QtWidgets -- no.uifile is used at runtimePython/explode_geometry.pyandBundle2/Contents/python/explode_geometry.py.uifile atPython/assets/explode_geometry.uiis the legacy PySide1 designer file and is not loaded at runtime -- the current code builds UI inlineDetailed Findings
C# Progress Bar Implementation (Reference)
XAML layout (
Source/XAML/ExplodeGeomUserControl1.xaml:29-39):Progress flow (
Source/XAML/ExplodeGeomUserControl1.xaml.cs:246-324):m_btnExplodeIt_Click: showsm_pnlProgressPanel(line 251)m_lblTotNodeto total selected nodes (line 274)m_lblNodeNameandm_lblCurrNode(lines 279-280)ADN_Utility.ConvertToTriangleFaces/ConvertToPolygonFaceswhich updatePB_ProgressCurrNumper facem_pnlProgressPanel(line 320) and clears the control (line 321)Per-face updates (
Source/ADNUtilities.cs:277-295):m_ctrlProgress.PB_ProgressMaxNum = nNumFacesm_ctrlProgress.PB_ProgressCurrNum = ++countPython Code That Needs Changes
Python/explode_geometry.py(main file, also duplicated inBundle2/Contents/python/explode_geometry.py):Ui_Form.setupUi()(lines 21-107): Add progress bar widgets between the explode button and the end of the layoutForm.do_explode()(lines 147-198): Show/hide panel, update labels, pass callback to conversion functionsconvert_to_triangle_faces()(lines 216-238): Accept and call progress callback per faceconvert_to_mnmesh_faces()(lines 241-261): Accept and call progress callback per faceFiles Requiring Changes
Python/explode_geometry.pyQProgressBar, progress info labels, and container widget tosetupUi()Python/explode_geometry.pyretranslateUitext for new progress labelsPython/explode_geometry.pydo_explode(): show/hide progress panel, update labels, pass callbackPython/explode_geometry.pyconvert_to_triangle_faces(): add progress callback, call per facePython/explode_geometry.pyconvert_to_mnmesh_faces(): add progress callback, call per faceBundle2/Contents/python/explode_geometry.pyPython/explode_geometry.pyImplementation Notes
QProgressBarfrom PySide6.QtWidgets.setVisible(False)and be set to.setVisible(True)when explode beginsQApplication.processEvents()after each progress bar update to prevent UI freezingon_progress=Nonecallback so they remain callable without a UI contextAdd 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 aQProgressBarper-face as each node is processed, and is hidden again before the dialog closes. BothPython/explode_geometry.pyand its identical copyBundle2/Contents/python/explode_geometry.pymust 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.uifile loaded at runtimemainLayout(line 104) -- the progress panel goes after itForm.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 processingconvert_to_triangle_faces()(lines 216-238) iterates faces 1 to N in forward orderconvert_to_mnmesh_faces()(lines 241-261) iterates faces N to 1 in reverse order -- a forward counter must be tracked separately for correct progress displayPython/explode_geometry.pyandBundle2/Contents/python/explode_geometry.pyare byte-for-byte identical and must both be updatedDesired End State
When the user clicks Explode:
QProgressBarfilling from 0 to 100% as faces are processed<name>" and "Node:XofY" (where X/Y are the current/total selected objects)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
.uidesigner file atPython/assets/explode_geometry.ui-- it is not loaded at runtimeapplySettings(),_GCProtector, or any unrelated codeImplementation Approach
self.progress_panel(aQWidgetwithQVBoxLayout, initially hidden) toUi_Form.setupUi()immediately after the explode button, with aQProgressBarand two info rowsretranslateUi()with the static label textForm.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 processingconvert_to_triangle_faces()andconvert_to_mnmesh_faces()as an optionalon_progress=Noneparameter that theFormpasses as a lambda updatingself.progress_barBundle2/Contents/python/explode_geometry.pyIMPORTANT: 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 textmainLayout.addWidget(self.explode_button)(line 104), createself.progress_panel = QtWidgets.QWidget(Form)withself.progress_panel.setObjectName("progress_panel")progressLayout = QtWidgets.QVBoxLayout(self.progress_panel)with appropriate margins/spacingself.progress_bar = QtWidgets.QProgressBar(self.progress_panel)withsetObjectName("progress_bar"), and setsetMinimum(0),setMaximum(100),setValue(0)QHBoxLayoutnode-name row containing: a fixedQLabel("Processing Node:") andself.lbl_node_name = QtWidgets.QLabel(self.progress_panel)withsetObjectName("lbl_node_name")QHBoxLayoutcounter row containing: a fixedQLabel("Node:"),self.lbl_curr_node = QtWidgets.QLabel(self.progress_panel)(setObjectName("lbl_curr_node")), a fixedQLabel("of"), andself.lbl_tot_node = QtWidgets.QLabel(self.progress_panel)(setObjectName("lbl_tot_node"))self.progress_panel.setVisible(False)to hide it initiallymainLayout.addWidget(self.progress_panel)after the explode button widgetretranslateUi(), addsetTextcalls for the two fixed-text labels ("Processing Node:" and "Node:" / "of") usingQCoreApplication.translateValidation: 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, andlbl_tot_nodeexist as attributes on theUi_Forminstance.Requirements from spec:
Files to Modify:
Python/explode_geometry.py--Ui_Form.setupUi()(after line 104) andUi_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
elsebranch indo_explode()(line 170, just beforewith pymxs.undo), addself.progress_panel.setVisible(True)andQtWidgets.QApplication.processEvents()forloop (TriMesh at line 174 and MNMesh at line 186), setself.lbl_tot_node.setText(str(len(transformation_set)))forloop (line 174), after the existingprint(...), add:self.lbl_node_name.setText(n.name),self.lbl_curr_node.setText(str(i)),QtWidgets.QApplication.processEvents()forloop (line 186), after the existingprint(...), add:self.lbl_node_name.setText(node.name),self.lbl_curr_node.setText(str(i)),QtWidgets.QApplication.processEvents()_prog(cur, tot)that callsself.progress_bar.setValue(int(cur * 100 / tot) if tot else 0)andQtWidgets.QApplication.processEvents(), then pass it ason_progress=_progtoconvert_to_triangle_faces()(line 176)_progcallback for MNMesh and pass it ason_progress=_progtoconvert_to_mnmesh_faces()(line 188)rt.redrawViews()(line 196) and beforeself.close()(line 198), addself.progress_panel.setVisible(False)andself.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:
Files to Modify:
Python/explode_geometry.py--Form.do_explode()(lines 147-198)TASK 3: Add
on_progressCallback to Conversion Functions [HIGH PRIORITY]Status: NOT STARTED
Milestone: Both conversion functions accept an optional
on_progresscallback and call it per face, keeping UI responsiveconvert_to_triangle_faces()signature (line 216), addon_progress=Noneas the last parameterconvert_to_triangle_faces(), before the face loop (after line 221), add:if on_progress: on_progress(0, num_faces)convert_to_triangle_faces()(after theapplySettingscall at line 237), add:if on_progress: on_progress(face_idx, num_faces)convert_to_mnmesh_faces()signature (line 241), addon_progress=Noneas the last parameterconvert_to_mnmesh_faces(), before the face loop (after line 245), add:if on_progress: on_progress(0, num_faces)and introduce_processed = 0convert_to_mnmesh_faces()(after theapplySettingscall at line 260), add:_processed += 1thenif on_progress: on_progress(_processed, num_faces)(note: the loop goes N to 1 in reverse so_processedprovides the forward count)Validation: Both functions can be called without
on_progress(defaultNonepath must not error). When called with a callback, it is invoked once before the loop (at 0) and once per face.Requirements from spec:
ADNUtilities.cs:277-295andADNUtilities.cs:433-449Files to Modify:
Python/explode_geometry.py--convert_to_triangle_faces()(lines 216-238) andconvert_to_mnmesh_faces()(lines 241-261)TASK 4: Mirror All Changes to Bundle2 [HIGH PRIORITY]
Status: NOT STARTED
Milestone:
Bundle2/Contents/python/explode_geometry.pyis identical toPython/explode_geometry.pyafter all changesBundle2/Contents/python/explode_geometry.pydiff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.py-- it should produce no outputValidation:
diff Python/explode_geometry.py Bundle2/Contents/python/explode_geometry.pyreturns exit code 0 with no output.Requirements from spec:
Files to Modify:
Bundle2/Contents/python/explode_geometry.py-- all sections matching Tasks 1-3Testing Strategy
Unit Tests:
Integration Tests:
Python/path and the Bundle2 package pathManual Testing Steps:
Python/andBundle2/paths<name>" and "Node: 1 of 1" labels show correctlyPerformance 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.@allankoechke commented on GitHub (Jun 23, 2026):
Implementation complete! PR ready for review: https://github.com/allankoechke/ADN-3dsMax-Explode-Geometry/pull/4
@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
@allankoechke commented on GitHub (Jun 24, 2026):
Implemented both requested changes in
Python/explode_geometry.pyand the mirroredBundle2/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
logginglibprint(...)calls with a stdliblogging.Logger("ExplodeGeometry")whoseStreamHandlerwrites to stdout (the MAXScript Listener).DEBUGwhen the checkbox is checked (all messages pass through) andWARNINGwhen unchecked (only warning/critical messages). Per-face/per-node info is logged atDEBUG; the "nothing selected" message islogger.errorand the missing-detached-node case islogger.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
.dllassemblies are unaffected — changes are Python-only.@allankoechke commented on GitHub (Jun 24, 2026):
If explode process succeed, lets print a message on maxscript listener with how long it took
@allankoechke commented on GitHub (Jun 24, 2026):
Added explode-duration reporting in
Python/explode_geometry.pyand the mirroredBundle2/Contents/python/explode_geometry.py.time.perf_counter()right before processing begins and measured again afterredrawViews()on a successful run.[ExplodeGeometry] Explode completed successfully in N.NN seconds.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.