[Bf-funboard] command-history, undo, scripting, and other goodies..

David Jeske davidj at gmail.com
Fri Jul 5 21:25:26 CEST 2013

This is a followup to some good points Harley brought up about
Command-History here...


I agree there is opportunity to improve Command-History. IMO, "where" it
lives is less important than "how it works" and how it's "easy to get to
and put away".

For example, I could imagine a workable design in the info bar if there was
a "push button" way to collapse or expand that area. Dragging it down is
very non-intuitive, and closing it runs into weird confusion over dragging
the header and the split-divider. Plus, if expanding it "runs into" another
subpanel division, the expand gets stuck.

For now, I think it's better if we talk more about the functionality and
less about exactly where it lives.  I also think we should consider this in
a larger scope including "current operator modal status-text", "tools ->
operator subpanel", operator stack, undo/redo, and the interactive python
console. This GSOC project is related..


Here is a totally random brainstorm of thoughts:

- How do the command-history, undo stack, and operator stack relate? How
can we make them more coherent? Can we combine any/all of them?

- What "should" the command history show? Right now it shows many
python/DNA aware actions, but has notable omissions ... like undo/redo. It
would also be nice if it was clearer which actions in the command-history
were undoable and which were not.

- (on the mac) I can't copy command-history entries to the clipboard, which
is probably the most useful thing I could do with it!

- Command History is a great stepping-stone for macros. When in the 3dview,
I would like to quickly open/expand one panel, and have access to
command-history, a python-scripting window, and some easy "scripting helper
tools". Perhaps a UI block which runs all commands over all selected
objects, or even just a Template that inserts "import bpy, for obj in
bpy.context.selected_objects:"...Then the I could paste lines from
command-history into the loop, tweak a few things, and boom. macro script.
Hit the run-button. oops, it's wrong. Hit Undo. Change it, try again.

Don't get me wrong, macroing is POSSIBLE today, but it's a heck of alot of
steps and confusion. For example, just now I decided to "emulate" the above
behavior. This is exactly what happened...

- duplicate the screen-layout
- split the timeline, replace the two panels with an info panel and a
- hit "new" on the text editor
- fish in the "templates" menu for a while before realizing it doesn't have
simple loop templates
- search google for how to loop over selected objects
- paste "for obj in bpy.context.selected.objects:" into the text-editor
- use the UI to toggle wireframe on one object
- look at command-history, hand-type the right thing into my script window
(no copy, on mac at least)
- hit run script
- RED ERROR: "Python script fail, look in the console for now"
- OOPS, screwed, no way to see the raw-tty console on MacOS at the moment...
- (after running Blender manually from a text-shell)
Traceback (most recent call last):
line 1, in <module>
    NameError: name 'bpy' is not defined
- add "import bpy"
Traceback (most recent call last):
line 3, in <module>
AttributeError: 'Context' object has no attribute 'selected'
- OOPS, I read the forum post wrong it was "bpy.context.selected_objects"
- great, run, VOILA! did what I expected..

------- and here are some thoughts:

- showing/hiding UI to do this was doable, but could have been easier.
especially if this is something i want to show/hide alot on every one of my

- The "templates" could be much easier to use, with more simple "loop over
stuff" templates...
- it's kind of annoying and confusing that a script compile error results
in a big red command-history line that doesn't go away even after I fix the
error and re-run the script...
- Python errors should be highlighted in the editor instead of just
spitting a stack-backtrace we can't even see.....
- there doesn't seem to be any way to UNDO what the script did!! The
run-script command-history line should have a big-easy "undo this" button
to undo everything the script did.. in case I need to adjust it and try
- Running the script didn't give me any warm-fuzzy-feeling that it actually
did what I expected... The log just says "bpy.ops.text.run_script()" It
could at least say "2 objects affected" or it could even spit out the
command-history lines for all the actions the script took... in a
collapsable section for that script-run..
- "selected_objects" is a somewhat non-standard naming.. "SelectedObjects"
would be easier to read/see and more standard... though this is debatable.

More information about the Bf-funboard mailing list