Hello, I am trying to utilize the Part.moveTo function to move a Node. Usually this works as expected/described in the documentation. However, I am running into a specific situation where it seems to be completely unresponsive and does not move the Node or change its actualBounds. The same line of code which is just node.moveTo(x, y) sometimes works and sometimes doesn’t. I’ve also tried using move directly instead with the same result.
So, my question is, assuming the parameters passed to moveTo are valid integers, is there any other reason that it would not actually move a Part/Node? Maybe some kind of diagram configuration or bounds restriction?
Edit: Upon further investigation, it seems that the issue arises when I happen to ask the node to move to the same position it is already at. Somehow this causes the node to be “stuck”, because no matter how many times I call moveTo after that point, it does not move. Hope that helps to get a better answer on what’s going on.
One other note I’ve discovered is that, like in your testing, the node does eventually follow the coordinate that’s given to the moveTo call. It’s just that in between multiple moveTo calls, the actualBounds doesn’t appear to update. So, when I make calculations based on the actualBounds it’s not “up to date” during runtime, but the end result is that the node does make the move.
Most likely something we’ve done in our code is causing the irregular behavior but just trying to see if there is any under-the-hood knowledge that might help narrow it down.
Part.move just sets GraphObject.position for non-Group Parts. (Or the Part.location if the second argument is true.)
For Groups, the move override first calls the super method, so it too sets GraphObject.position. Then it calls Group.findSubGraphParts, prevents links from rerouting, moves all of the nodes and links, and then enables link rerouting. Hopefully none of the links will need to be routed again, but it might be necessary if the nodes changed relative position or if they changed size due to the move or if they are AvoidsNodes links that now cross over some nodes.
So, it’s possible for some of the links that are moved to have invalid routes for a while, before the end of the transaction. And the same goes for nodes.
If you could describe more why you have repeated calls to move, and the circumstances in which you are making those calls, it might help.