Freezing progress bar during node move

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)
Answers
-
Not sure why. A work around you can make two text boxes as read only with different colors and change the length of the “progress” box from 0 to total width.
Maybe that would expose what is going on with the progress bar?
0 -
Individual node move is also not really intended to scale to lots of nodes. I would consider moving the nodes at the solver level with APDL commands. It’s not wrong, it just wont be fast with lots of nodes move operations
0 -
Thank you for the help. I have now chosen the variant with the stacked text boxes, which looks a bit cleaner and runs better. However, this variant is still not entirely clean, as the GUI continues to freeze and does not run smoothly even in a separate thread.
Regarding the topic of Node Move, the APDL code is faster, etc. However, there are reasons for the switch to Python. The reasons are that Python is more modern, readable and maintainable (OOP, etc.), making it easier for colleagues to work on the code in the future, implement new features, rewrite, refactor, etc.
It would be nice if there was a function where you could pass a list of nodes along with their new coordinates, instead of dealing with individual nodes. But as I mentioned, I have already asked about this in another thread.0