I'm learning Blender Python and trying a few one-liners in the console in the scripting layout. You can imagine that it would be really handy to be able to undo one line of command in the console, because obviously I'm going to often end up executing commands I don't mean to. BUT, when I press Cmd + Z (I'm on Mac), it undoes all the commands I've inputed into the console since I opened Blender. That's weird to me. How do I undo only the last command I input in the console?
- The suggestion is ... do [not] rely on the concept of undoing any action in the Console window.
Use the Text Editor window for functions you write for long term value
By writing functions and executable statements in Python in the [Text Editor] window you can more easily test your concepts, and save your work with Blender or as an external file.
The written record is invaluable.
Clearly the [add ons] of Blender are written with a text editor and saved as files.
- The console is superb for investigating structures with statement completion and dir and type. 1 to 3 lines of Python is useful. (Replace 3 with your personal Python number comfort level). There are some add ons (probably) that will assist in the exploration as well.
- In MS-Windows I use the up-arrow key to type again the last statements.
- The Blender [user] interface allows a concept of configurable Undo.
- Be careful not to do undo desired typing in the text editor window
- If Python in the console deletes a OS file, I would not expect Python to restore it. Not a simple example and perhaps I have not looked for an api that performs that service.
In the Blender screen capture above a function is written at the top of some file and invoked at the bottom of the same file. Alt-A invokes the script. There is a button as well on the menu bar .. not shown. The above example is just some random sample and only meant to show a function definition and call of the same function.
Console for Simple Ops
When the Python Console was used for simple operations, Undo worked in the (different) 3D View window. Image above. Console do action. 3D View Undo action. As a quick preview for further study please note the following. I looked at the text in the [Info] window as a means to write the text in the [Console] window. The info windows presented the Python of my manual user actions. I may have never used the the translate function before. It is no longer critical that I remember.