What OpticStudio version are you using? In 20.3.2 (my version), I cannot adjust it through the API. You can access TheApplication.Preferences.General, but for me, Undo is not exposed.
If you use Standalone mode, you could use the code of Example 26 of ZOSAPI help:
But I guess that does not work for extension mode (as the application is already up and running). Unless Undo is exposed in newer versions of the API, you will have to set it manually to None before connecting.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.