I ran into an issue today and I have duplicated the issue in both 2021 and 2025. It seems as though if you are using the pick command from the command manager and try to use it in a looping situation to add a pick to a Select Set the pick reset the Select set until the end of the pick. From what I can tell it should iterate through the loop adding the entities to the Select Set and highlighting the appropriate entities. But it doesn't do that until the Pick command is escaped out of or ended.
Here is the code that I used I have tried a Do loop, While loop and a goto command, and all have the same outcome.
Community thread talking about this issue.
https://forums.autodesk.com/t5/inventor-programming-ilogic/select-sets-do-loops-and-winforms/m-p/129...