Enter error message or question

Hi Ansys-Team,

I've a question about updating a progress bar, which I created with Windows Forms.
When I go through a nested loop, I try to update every 25% the progress bar, which works for the label I created in the progress bar ui, but the progessbar itself is behind. For example when I reach 25%, the label shows 25%, but the progress bar is at 0. When the label is updated to 50%, which works, the progress bar shows 25%. Is there a solution for this?


totalNodesToMove = len(dataToMoveNodeList) * len(mesh.Nodes)
progressStep = max(1, int(totalNodesToMove * 0.25))
nextProgressUpdate = progressStep
pb = ProgressBarForm.ProgressBarForm(100, path)
percent = 0
pb.Show()

with Transaction(True):
i = 1
for data in dataToMoveNodeList:
for node in mesh.Nodes:
node_y = node.Y
#some other code

                if i >= nextProgressUpdate:
                    percent = (i * 100) // totalNodesToMove
                    pb.update_progress(percent, "Circumferential")
                    #ExtAPI.Application.InvokeBackground(lambda p=percent: pb.update_progress(p, "Circumferential"))
                    nextProgressUpdate += progressStep
                    System.Windows.Forms.Application.DoEvents()
                i += 1

                #Go to next node if rm is more or less equal to new calculated radius. This should save a lot of time for node move.
                if round(math.sqrt(math.pow(newX, 2) + math.pow(newZ, 2)), 4) == round(middle_radius, 4) or abs(fraction) <= 1e-12:
                    continue

                newLocX = Quantity(newX * correctionScaling, "m")
                newLocY = Quantity(node.Y * correctionScaling, "m")
                newLocZ = Quantity(newZ * correctionScaling, "m")
                nodeMove.MoveNode(node.Id, newLocX, newLocY, newLocZ)