Hi @Kotaru_1 !
That contextual menu option internally calls GEditor->ToggleSelectedActorMovementLock();
in C++. I’m reading the source code and it actually iterates over all of the selected actors, so if you first select all of the actors that you want to lock it should apply the lock to the whole selection. If you want to automate this via C++ then the process would be to first select the actors and then call that function in GEditor.
I hope this helps!