While working on a scene and moving things around I found myself wishing there was a way to “bookmark” an object’s location and rotation, so that if I wanted to move one or more objects and then decide to move them back to their previous conditions I could do so.
One can set a LocRot key of course for an object if it’s a static scene, but this is not always a good practice, especially if you’re working on an animation where there may be existing IPOs you may not want to disturb during multiple changes while attempting to tweak scenes for better results.
So I wrote a script tonight that uses Empty objects as virtual bookmarks for any objects you select.
While I created this to allow me more freedom in changing my mind in placing models and setting up scenes, there are lots of reasons why it might be useful to have these automated Empties, including possible animation purposes and even visual placeholders in densely populated scenes.
To use it, have some objects selected, load up the script, place the mouse cursor over the Blender text window where you have the script loaded, and press ALT P.
Now, if you move or further rotate objects you can set them back to their original settings by using their newly created Empties. Activate Layer 20 (or whatever layer you set them to) if you don’t see them, then first select an object and then its corresponding Empty and press CTRL C and select Location to copy the location of the Empty and then CTRL C and select Rotation to copy the rotation of the Empty.
By default, the script places newly created Empties on Layer 20. This behavior can be easily modified by altering one variable in the script. The script contains instructions on how to do this and some other things.
Here is a sample .blend file with primitives and the script.
Here is a text version of the script on its own:
# "Empty Placeholder Creation Script" # by RobertT, 2005 # # Created on July 29, 2005 # Tested on Blender 2.37a # # # What This Python Script Does: # # This script creates a new Empty object # for all selected objects in your scene # and places the new Empties on Layer 20. # # There are instructions below in the code # for you to have each Empty placed on an # object's own layer. # # The new Empties are configured to each # selected object's location and rotation. # # You can use these new Empties for many # different purposes. They can be visual # placeholders, or can be used to "bookmark" # an object's current location/rotation # so you can then reposition that object # and set it back to its previous loc/rot # by selecting first the object, then its # corresponding Empty, then pressing # CTRL C and copying Location and then # CTRL C again and copying Rotation. # # You can also use these versatile Empties # for parenting and animation purposes. # # # Concerning Usage and Adaptation: # # Use and adapt this script # however you want :-) import Blender objects = Blender.Object.GetSelected() scene = Blender.Scene.getCurrent() # You can edit the whatLayer variable # to have newly created Empties placed in # the layer of your choice (from 1 to 20) whatLayer = 20 # Alternately, you can edit this code # to have the Empty placed on the same # layer as its object by placing a # # character in front of the variable # above and then removing the # # character from the whatLayer # variable below: for obj in objects: loc = obj.getLocation() if obj.getType() != 'Empty': newEmpty = Blender.Object.New ('Empty') newEmpty.setLocation (loc,loc,loc) # The next three lines of code # set the new Empty to an object's # X/Y/Z Rotation settings. # You can place a # character before # the next three lines so the Empty # remains unrotated (possibly useful # for animation or other purposes). newEmpty.RotX = obj.RotX newEmpty.RotY = obj.RotY newEmpty.RotZ = obj.RotZ scene.link (newEmpty) #whatLayer = obj.layers newEmpty.layers = [whatLayer] Blender.Redraw()
I hope someone out there finds this useful
As it says in the script, use it however you want