0
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ I would be tempted to say that it's a bug that everything gets undone. I would think either undo should not work in the python console at all or it should do individual steps. $\endgroup$ – Ray Mairlot May 6 '16 at 16:28
  • 1
    $\begingroup$ Doesn't Global Undo solve this? $\endgroup$ – someonewithpc Jul 5 '16 at 20:23
1
$\begingroup$

enter image description here

  • 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

enter image description here

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.

$\endgroup$
  • $\begingroup$ I agree with most of what you say but this is not my work flow. I need to quickly test things like rotating objects by a certain angle, and undoing it if the angle is not what I intended. This is best done by using the console (right?). If normal GUI operations like the rotation I mentioned above can be undone (one operation at a time), I don't see why one-liner console operations can't be undone one at a time. $\endgroup$ – Ray May 6 '16 at 15:52
  • $\begingroup$ The point of testing one-liners in the console is so I can see if the Python code works. Of course I can achieve the same effect in the GUI but that defeats the point of quick-testing a line of code you see? I do appreciate your help by the way, please don't think me ungrateful. $\endgroup$ – Ray May 6 '16 at 16:13
  • $\begingroup$ For simple ops why not do the same in the GUI and then [undo]? I cannot know you unique workflow. Time might expire if I inquire for details. You can also do simple ops in the Console and Undo in the GUI, $\endgroup$ – atomicbezierslinger May 6 '16 at 16:22
  • 1
    $\begingroup$ You can see if the Python code works in the text editor window as well. What is a short cut for one person may be a long extension for another person. I have no deep interest in changing your style. I am stating that style does not work for me. The Undo issue has been minimally addressed above. I am encouraging you to try both styles and compare. The decision is yours and yours alone. $\endgroup$ – atomicbezierslinger May 6 '16 at 16:29
  • $\begingroup$ OK I will tray a few things and see what suits me best. Thank you for your suggestions! $\endgroup$ – Ray May 6 '16 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.