I wanted a way to perform a “Repeat Last Action” command in Blender. I found an easy way to do it on Ubuntu Linux with a little tool called xmacro. Xmacro is a simple keyboard and mouse recording utility. It will record keystrokes that can be played back at a later time. It is quite old but it works with a little help.
Step 1. Install Xmacro
$ sudo apt-get install xmacro
Step 2. Install Nick’s Helper Scripts
Save these two scripts somewhere on your Linux box.
record_macro.bash:
#!/usr/bin/env bash
ESC_KEY_CODE=9
# A delay is needed to ensure all keys are released that
# activate the macro prior to recording.sleep 1.0
# Press escape to stop recording the macro.
xmacrorec2 -k $ESC_KEY_CODE | tee /tmp/temp_xmacro.txt
play_macro.bash:
#!/usr/bin/env bash
# WARNING, a delay is needed to ensure all keys are released
# that activate the macro playback, if a key is still being
# held on the keyboard, who knows what key combinations will
# play on your desktop!sleep 0.5
# A loop is used to control the playback speed.
while read line; do
echo $line | xmacroplay $DISPLAY
sleep 0.005 # the delay between events
done < /tmp/temp_xmacro.txt
Step 3. Assign Macro Scripts To The Keyboard
In Gnome, open up the keyboard shortcuts by selecting: System –> Preferences –> Keyboard Shortcuts
Click on the Add button at the bottom.
Name: Record Macro
Command: /install_path/record_macro.bash
where install_path is the location you saved the helper scripts.
Next, assign a keyboard shortcut to “Record Macro”, I use CTRL+ALT+M
Click on the Add button again.
Name: Play Macro
Command: /install_path/play_macro.bash
where install_path is the location you saved the helper scripts.
Next, assign a keyboard shortcut to “Play Macro”, I use CTRL+ALT+P
Step 4. Try It Out In Blender
Open Blender, with the default cube open, enter edit mode.
We’ll record extruding two verticies.
Select two verticies.
Now press CTL+ALT+M to start macro recording.
Press e
Press RETURN
Press x
Press 1.0
Press RETURN
Press ESCAPE
Pressing ESCAPE will end macro recording.
Now repeat the last action by pressing CTR+ALT+P. Make sure you release the keys on the keyboard while the macro plays!
Enjoy!
-Nick