Friday, October 08, 2010

Make pig 0.7.0 work with Hadoop 21?

I was trying to learn how to use Pig.

My hadoop version is 0.21.0, and my pig version was 0.7.0.

In line with the the instructions on Hadoop The Definitive Guide, I set the environment variables as following:

/usr/local/pig/bin$ printenv | grep PIG
PIG_HOME=/usr/local/pig
PIG_INSTALL=/usr/local/pig
PIG_HADOOP_VERSION=21
PIG_CLASSPATH=/usr/local/hadoop/conf

Then when I was trying to run pig, I was getting the following error:
/usr/local/pig/bin$ pig
10/10/08 22:15:16 INFO pig.Main: Logging error messages to: /opt/pig-0.7.0/bin/pig_1286601316333.log
2010-10-08 22:15:16,978 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://mini:54310
2010-10-08 22:15:17,632 [main] ERROR org.apache.pig.Main - ERROR 2999: Unexpected internal error. Failed to create DataStorage
Details at logfile: /opt/pig-0.7.0/bin/pig_1286601316333.log

Looking at the list of files under pig/lib:
/usr/local/pig/lib$ ls -lt
total 34240
-rw-r--r--@ 1 hadoop admin 807 May 5 11:19 hadoop-LICENSE.txt
-rw-r--r--@ 1 hadoop admin 8006352 May 5 11:19 hadoop20.jar
drwxr-xr-x@ 4 hadoop admin 136 May 5 11:19 jdiff
-rw-r--r--@ 1 hadoop admin 4784831 May 5 11:19 hadoop18.jar
-rw-r--r--@ 1 hadoop admin 171596 May 5 11:19 automaton.jar
-rw-r--r--@ 1 hadoop admin 1916683 May 5 11:19 hbase-0.20.0-test.jar
-rw-r--r--@ 1 hadoop admin 1530035 May 5 11:19 hbase-0.20.0.jar
-rw-r--r--@ 1 hadoop admin 1109768 May 5 11:19 zookeeper-hbase-1329.jar
/usr/local/pig/lib$

I wasn't sure if hadoop 21 was supported.

So I added the following in bin/pig, which is a bash script:

# HINADA
# exec "$JAVA" $JAVA_HEAP_MAX $PIG_OPTS -classpath "$CLASSPATH" $CLASS ${remaining}
exec "$JAVA" $JAVA_HEAP_MAX $PIG_OPTS -classpath "/usr/local/hadoop/hadoop-common-0.21.0.jar:/usr/local/hadoop/hadoop-hdfs-0.21.0.jar:/usr/local/hadoop/hadoop-mapred-0.21.0.jar:$CLASSPATH" $CLASS ${remaining}

With this, when I type pig, now I get:

/usr/local/pig/bin$ pig
10/10/08 22:18:03 INFO pig.Main: Logging error messages to: /opt/pig-0.7.0/bin/pig_1286601483112.log
2010-10-08 22:18:03,570 [main] WARN org.apache.hadoop.conf.Configuration - user.name is deprecated. Instead, use mapreduce.job.user.name
2010-10-08 22:18:03,573 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: local
2010-10-08 22:18:03,716 [main] INFO org.apache.hadoop.security.Groups - Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000
2010-10-08 22:18:03,833 [main] WARN org.apache.hadoop.conf.Configuration - mapred.task.id is deprecated. Instead, use mapreduce.task.attempt.id
2010-10-08 22:18:04,170 [main] WARN org.apache.hadoop.conf.Configuration - user.name is deprecated. Instead, use mapreduce.job.user.name
grunt>

Now I can see the grunt prompt!

However, my happiness was short-lived...

When I ran the DUMP tasks, I was getting the following error in the log:

ERROR 2998: Unhandled internal error. org.apache.hadoop.mapred.jobcontrol.JobControl.addJob(Lorg/apache/hadoop/mapred/jobcontrol/Job;)Ljava/lang/String;

I installed Hadoop 20, and used Pig with Hadoop 20, and the problem does not happen, so I need to stick with Hadoop 20 for now.

I posted my experiences at my website below:
https://sites.google.com/site/winstoninada/playing-with-pig

Wednesday, October 06, 2010

Saturday, January 05, 2008

Blender Python script to automate the creation of closing credits

Here is a sample Blender Python script to automate the creation of closing credits screen from a text file. In addition to closing credits, you can also use this script to scroll text.

The text file is read line by line, and a corresponding Text3d object is created, which will in turn become a child of an Empty object.
Key frames are created to move the location of the Empty object to scroll.
The scroll speed can be adjusted by changing the end frame value (nEndFrame).




Here is the sample video I made using this script.





To use this the code, you need the following three files:



closingCredits.py

textFile.py

closingCredits.txt



Put closingCredits.py and textFile.py in Blender's scripts directory.
Edit closingCredits.txt using a text editor, and and put it in /tmp.
--- BEGIN closingCredits.py ---


#!BPY

"""
Name: 'Closing Credits generation'
Blender: 244
Group: 'Animation'
Tooltip: 'Generate Closing Credits from a text file.'
"""

__author__ = "Hide Winston Inada"
__version__ = "0.9.1 Jan 05, 2008"

__bpydoc__ = """\
This script generates closing credits from a text file.
"""

# $Id: $
# ***** BEGIN GPL LICENSE BLOCK *****
# Script Copyright (C) 2007, Hide Winston Inada, hideyuki _at_ gmail.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ***** END GPL LICENCE BLOCK *****

# ***** Blender modules *****
import Blender
from Blender import Window
from Blender import NMesh
from Blender import Object
from Blender import Mesh
from Blender import Scene
from Blender import Text3d
import bpy

# ***** Python modules *****
import math

# ***** Hide's helper modules *****
import textFile

# ***** Configurable parameters
sClosingCreditsPath = "/tmp/closingCredits.txt"
# this may map to c:\tmp under MS Windows

nNewStartFrame = 1
nNewCurrentFrame = 1
nNewEndFrame = 600

nSpaceBetweenLinesY = 1

# ***** Code start *****

def main():
# Standard start up code
print "\nStarting closingCredits.py"
sce = bpy.data.scenes.active
activeObject = sce.objects.active

# Read text file
aClosingCredits = textFile.readFileToList(sClosingCreditsPath)
if(aClosingCredits == None):
print "Error in reading the closing credits file."
print "Check to make sure that it is located at"
print sClosingCreditsPath
return

nNoLines = len(aClosingCredits)
if(nNoLines < 1):
print "The file " + sClosingCreditsPath + " is empty."
return
else:
print (str(nNoLines) + " lines have been read")

nOriginalStartFrame = Blender.Get('staframe')
nOriginalCurrentFrame = Blender.Get('curframe')
nOriginalEndFrame = Blender.Get('endframe')

Blender.Set('curframe', nNewCurrentFrame)

cxt = sce.getRenderingContext()
cxt.startFrame(nNewStartFrame)
cxt.endFrame(nNewEndFrame)

Window.RedrawAll()

nResult = Blender.Get('staframe')
if(nNewStartFrame != nResult) :
print("Error in setting the start frame")
return

nResult = Blender.Get('endframe')
if(nNewEndFrame != nResult) :
print("Error in setting the end frame")
return

nResult = Blender.Get('curframe')
if(nNewCurrentFrame != nResult) :
print("Error in setting the current frame")
return

# create an empty object
owEmpty = Blender.Object.New('Empty')
sce.objects.link(owEmpty)
owEmpty.setName('emptyParent')

aChildList = []
i = 0
for i in range(0, i+nNoLines) :

# create Data object for text
textDO = Text3d.New("textDataObj" + str(i))
textDO.setText(aClosingCredits[i])

# create object wrapper for text
ow = sce.objects.new(textDO)
ow.setName("textObjectWrapper" + str(i))
aChildList.append(ow)
ow.LocX = 0
ow.LocY = -nSpaceBetweenLinesY * i
ow.LocZ = 0

# Make Empty object the parent object for all text objects
owEmpty.makeParent(aChildList)

obj = owEmpty

i = 0
Blender.Set('curframe', nNewStartFrame)
obj.LocY = 0
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

Blender.Set('curframe', nNewEndFrame)
obj.LocY = nNoLines * nSpaceBetweenLinesY
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

ow.makeDisplayList()
Window.RedrawAll()

print ("Completed")
# end main

main()



--- END closingCredits.py ---



--- BEGIN textFile.py ---


# $Id: $
# ***** BEGIN GPL LICENSE BLOCK *****
# Copyright (C) 2008, Hide Winston Inada, hideyuki _at_ gmail.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ***** END GPL LICENCE BLOCK *****

def readFileToList(sFilePath, bRStrip=True):
# Var
aText = []

# Code
try:
f=open(sFilePath, 'r')
except IOError:
print("Cannot open " + sFilePath)
return(None)
else:
try:
while (True) :
sReadLine = f.readline()
if(sReadLine == '') :
break

if(bRStrip == True) :
sReadLine = sReadLine.rstrip()
aText.append(sReadLine)

except IOError:
print("Error while reading " + sFilePath)
f.close()
return(None)
else:
f.close()
return(aText)

--- END textFile.py ---

--- BEGIN closingCredits.txt ---


Blender Closing Credits Generation Demo



Directed by Hide Inada


Produced by Hide Inada



Sample output




CAST

Role 1 Actor1
Role 2 Actor2
Role 3 Actor3
Role 4 Actor4
Role 5 Actor5
Role 6 Actor6
Role 7 Actor7
Role 8 Actor8
Role 9 Actor9
Role 10 Actor10
Role 11 Actor11
Role 12 Actor12
Role 13 Actor13
Role 14 Actor14
Role 15 Actor15
Role 16 Actor16
Role 17 Actor17
Role 18 Actor18
Role 19 Actor19
Role 20 Actor20
Role 21 Actor21
Role 22 Actor22
Role 23 Actor23
Role 24 Actor24
Role 25 Actor25
Role 26 Actor26
Role 27 Actor27
Role 28 Actor28
Role 29 Actor29
Role 30 Actor30
Role 31 Actor31
Role 32 Actor32
Role 33 Actor33
Role 34 Actor34
Role 35 Actor35
Role 36 Actor36
Role 37 Actor37
Role 38 Actor38
Role 39 Actor39




STAFF

Staff Role1 Staff1
Staff Role2 Staff2
Staff Role3 Staff3
Staff Role4 Staff4
Staff Role5 Staff5
Staff Role6 Staff6
Staff Role7 Staff7
Staff Role8 Staff8
Staff Role9 Staff9
Staff Role10 Staff10
Staff Role11 Staff11
Staff Role12 Staff12
Staff Role13 Staff13
Staff Role14 Staff14
Staff Role15 Staff15
Staff Role16 Staff16
Staff Role17 Staff17
Staff Role18 Staff18
Staff Role19 Staff19
Staff Role20 Staff20
Staff Role21 Staff21
Staff Role22 Staff22
Staff Role23 Staff23
Staff Role24 Staff24
Staff Role25 Staff25
Staff Role26 Staff26
Staff Role27 Staff27
Staff Role28 Staff28
Staff Role29 Staff29
Staff Role30 Staff30
Staff Role31 Staff31
Staff Role32 Staff32
Staff Role33 Staff33
Staff Role34 Staff34
Staff Role35 Staff35
Staff Role36 Staff36
Staff Role37 Staff37
Staff Role38 Staff38
Staff Role39 Staff39


Copyright (C) 2008 Hide Winston Inada.
All rights reserved.

--- END closingCredits.txt ---

Wednesday, January 02, 2008

Demo Blender Python script to automate the keyframe insertion

Here is a demo Blender Python script to automate the keyframe insertion.
In this demo, keyframes are created at the object level, or IPO level (instead of vertex level).
In the sample video below, I used the monkey mesh model called Suzanne which comes with Blender.
This scripts adjusts the location and rotation at each keyframe.





--- BEGIN Script ---


#!BPY

"""
Name: 'Automated IPO keyframe insertion demo'
Blender: 244
Group: 'Animation'
Tooltip: 'Demo for automated IPO keyframe insertion using Python'
"""

__author__ = "Hide Winston Inada"
__version__ = "0.9 2008-1-03"

__bpydoc__ = """\
This script is a demo to show automated IPO keyframe insertion using Python.
"""

# $Id: $
# ***** BEGIN GPL LICENSE BLOCK *****
# Script Copyright (C) 2007, Hide Winston Inada, hideyuki _at_ gmail.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ***** END GPL LICENCE BLOCK *****

import math

import Blender
from Blender import Window
from Blender import NMesh
from Blender import Object

import bpy

# Variables
nNewStartFrame = 1
nNewCurrentFrame = 1
nNewEndFrame = 120

nNoFrames = nNewEndFrame - nNewStartFrame + 1
nFirstKeyFrame = nNewStartFrame - 1 + nNoFrames/4
nSecondKeyFrame = nNewStartFrame - 1 + (nNoFrames/4)*2
nThirdKeyFrame = nNewStartFrame - 1 + (nNoFrames/4)*3

# Debug print out
print ("")
print ("Starting demo for automated IPO keyframe insertion using Python")
print ("Configurable parameter listing:")
print ("Start frame : " + str(nNewStartFrame))
print ("End frame : " + str(nNewEndFrame))
print ("Current frame : " + str(nNewCurrentFrame))
print ("Number of frames : " + str(nNoFrames))
print ("First keyframe : " + str(nFirstKeyFrame))
print ("Second keyframe : " + str(nSecondKeyFrame))
print ("Third keyframe : " + str(nThirdKeyFrame))
# Debug print out end

activeScene = bpy.data.scenes.active
activeObject = activeScene.objects.active

# Setting start, end, current frames
nOriginalStartFrame = Blender.Get('staframe')
# print("Original start frame : " + str(nOriginalStartFrame))

nOriginalCurrentFrame = Blender.Get('curframe')
# print("Original current frame : " + str(nOriginalCurrentFrame))

nOriginalEndFrame = Blender.Get('endframe')
# print("Original end frame : " + str(nOriginalEndFrame))

Blender.Set('curframe', nNewCurrentFrame)

cxt = activeScene.getRenderingContext()
cxt.startFrame(nNewStartFrame)
cxt.endFrame(nNewEndFrame)

Window.RedrawAll()

# Verifying to see if frames are set correctly
nResult = Blender.Get('staframe')
if(nNewStartFrame != nResult) :
print("Error in setting the start frame")

nResult = Blender.Get('endframe')
if(nNewEndFrame != nResult) :
print("Error in setting the end frame")

nResult = Blender.Get('curframe')
if(nNewCurrentFrame != nResult) :
print("Error in setting the current frame")

# Keyframe insertion
obj = activeObject

Blender.Set('curframe', nNewStartFrame)
obj.LocX = 0
obj.LocY = 0
obj.LocZ = 0
obj.RotZ = math.radians(90)
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

Blender.Set('curframe', nNewEndFrame)
obj.LocX = 0
obj.LocY = 0
obj.LocZ = 0
obj.RotZ = math.radians(360+90)
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

Blender.Set('curframe', nFirstKeyFrame)
obj.LocX = 4
obj.LocY = 0
obj.LocZ = 0
obj.RotZ = math.radians(180)
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

Blender.Set('curframe', nSecondKeyFrame)
obj.LocX = 4
obj.LocY = 4
obj.LocZ = 0
obj.RotZ = math.radians(270)
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

Blender.Set('curframe', nThirdKeyFrame)
obj.LocX = 0
obj.LocY = 4
obj.LocZ = 0
obj.RotZ = math.radians(360)
obj.insertIpoKey(Object.IpoKeyTypes.LOCROTSIZE)

# Finalization
print("Completed")

# References
# 1. For setting start, end frames, see:
# http://blenderartists.org/forum/archive/index.php/t-62993.html




--- END Script ---

Thursday, December 27, 2007

Poser Python script to make a figure breathe

Here is a Python script to automate the key frame insertion and posing of having a Poser figure breathe.
In this code, I also used the model JessicaCasual which comes with Poser 6 as in my blinking example.
This scripts adjusts the size of the chest and abdomen in a cyclical manner.




Here is the generated video. Please note that the blinking script was also used.

--- BEGIN Script ---


# Copyright (C) 2007 Hideyuki Inada. All rights reserved.
#
# Note: Please adjust the end frame of the animation using the UI.

# Parameters
nStartFrame = 0
nEndFrame = 300

nFramePerSecond = 30

sParameterName = "xScale"
sParameter2Name = "zScale"

nBreathingPerMinute = 16 # See ref 1 below
nCycleDurationInFrame = 60 * nFramePerSecond / nBreathingPerMinute
nHalfCycleDurationInFrame = int(nCycleDurationInFrame / 2)

# Helper method
def debugPrint(sArg):
print(sArg)


def insertKeyFrameAndSetValue(nFrame, oScene, oActor, sParameterName, nParameterValue):
oScene.SetFrame(nFrame)
oActor.SetParameter(sParameterName, nParameterValue)
oActor.AddKeyFrame(nFrame)

# main start
debugPrint("Script starting")
debugPrint("Running on Poser version " + poser.Version())

# Obtain the reference to the Scene object
sce = poser.Scene()

# Setting ranges
sce.SetOutputRange(nStartFrame, nEndFrame)

mm = sce.MovieMaker()
mm.SetOutputStartFrame(nStartFrame)
mm.SetOutputEndFrame(nEndFrame)

fig = sce.Figure("JessicaCasual")
actor = fig.Actor("Chest")
actor2 = fig.Actor("Abdomen")

# Setting poses and inserting key frames

insertKeyFrameAndSetValue(0, sce, actor, sParameterName, 0)

bLastState = 1
# See ref 2 if you can use the keyword "True" here in your environment
# In my enviroment, 1 is used since "NameError: name 'True' is not defined" was displayed
# during run-time

for i in range(nStartFrame, nEndFrame):
if (i % nHalfCycleDurationInFrame == 0):
if(bLastState == 1):
insertKeyFrameAndSetValue(i, sce, actor, sParameterName, 0.98)
insertKeyFrameAndSetValue(i, sce, actor, sParameter2Name, 0.98)

insertKeyFrameAndSetValue(i, sce, actor2, sParameterName, 0.98)
insertKeyFrameAndSetValue(i, sce, actor2, sParameter2Name, 0.98)

bLastState = 0
else:
insertKeyFrameAndSetValue(i, sce, actor, sParameterName, 1.02)
insertKeyFrameAndSetValue(i, sce, actor, sParameter2Name, 1.02)

insertKeyFrameAndSetValue(i, sce, actor2, sParameterName, 1.02)
insertKeyFrameAndSetValue(i, sce, actor2, sParameter2Name, 1.02)

bLastState = 1

debugPrint("Script completed")
# end of code

# References
# 1. http://answers.yahoo.com/question/index?qid=20070715141510AAaQ71b
# 2. http://docs.python.org/lib/node8.html



--- END Script ---

Poser python script to make a figure blink

Here is a Python script that I wrote to automate the insertion of key frames in order to avoid the manual work in making a Poser figure blink.
In this code, I used the model JessicaCasual which comes with Poser 6, and the blinking parameter is associated with her Head, so if you want to use this code for other figures, please tweak them as needed.

Please also note that I am using both Spline and Linear curves.
Spline is used when you are closing her eyes, and Linear is used between two key frames where eyes are open.

If you do not do this, then depending on how key frames are set, the value of the "Blink" parameter can go out of the 0 to 1 range due to the way the curve are interpolated from a few key frames which can mess up the animation.

Here is the generated animation that I posted to Google Video. http://video.google.com/videoplay?docid=-7199780183159438675

Hide Inada

--- BEGIN Script ---


# Copyright (C) Hideyuki Inada 2007. All rights reserved.
# Adjust the end frame of the animation manually in the UI for now.

sce = poser.Scene()
fig = sce.Figure("JessicaCasual")
head = fig.Actor("Head")

startFrame = 0
endFrame = 300

sce.SetOutputRange(startFrame, endFrame)

mm = sce.MovieMaker()
mm.SetOutputStartFrame(startFrame)
mm.SetOutputEndFrame(endFrame)

# start off by opening the eye
i = 0
sce.SetFrame(i)
head.SetParameter("Blink", 0)
head.AddKeyFrame(i)

nPrevFrame = 0

for i in range(startFrame, endFrame):
if ( (i % 20 == 0) and (i % 60 != 0) ):
# Open

head.SetRangeLinear(nPrevFrame, i)
for j in range(i, i+2):
sce.SetFrame(j)
head.SetParameter("Blink", 0)
head.AddKeyFrame(j)
nSplineFrameStart = i + 1

# Close
j = i + 5
sce.SetFrame(j)
head.SetParameter("Blink", 1)
head.AddKeyFrame(j)

# Open
for j in range(i+9, i+11):
sce.SetFrame(j)
head.SetParameter("Blink", 0)
head.AddKeyFrame(j)

head.SetRangeSpline(nSplineFrameStart, i + 9)
nPrevFrame = i + 10



--- END Script ---

Saturday, December 08, 2007

Blender scripts to evenly space objects

Here is the is the link to Blender scripts to evenly space Blender objects:

Download ZIP

In other words, the distance between two objects will be set to the same, and this distance will be calculated by evenly dividing the distance between the object which has the largest value for the axis and another object which has the smallest value for the axis.

How to install
Prerequisite: Please make sure that you have Blender 2.44 or above installed on your computer.

1. Unzip and copy these three scripts to "./blender/scripts" directory under your Blender installation.
For example, on MacOS, if you install Blender under /Application, the directory may be:
/Applications/blender-2.44-OSX-10.3-py2.3-powerpc/blender.app/Contents/MacOS/.blender/scripts

If you are using MS Windows, you may need to download the zipped version of Blender that contains ".blender/script" folder instead of using the installer to install Blender.

2. Display "Scripts Window" by selecting "Scripts Window" in the "Window type" icon at the top left of one of your windows.

3. In Scripts Window, Select "scripts | Update Menus" menu item.
This registers the script under the "Scripts | Object" menu.

4. Verify that "Evenly Space x" menu item is displayed under the "Scripts | Object" menu.

How to use
Prerequisite : Save your work before running the script!

1. Go to the 3D View window.
2. While in Object mode, select multiple objects that you want to evenly space in 3D View. You have to select three or more objects since you have to have a set of two distances to adjust.
For example, if you select only two objects, there is only one distance, and the script will exit as there is nothing to do.
The order that you select objects does not matter.
3. Go to the Scripts Window.
4. Select "Scripts | Object | Evenly Space x " menu item to evenly space along the x axis. location. Use "Evenly Space y" or "Evenly Space z" for y or z axes.

If you have questions, please email me at hideyuki _at_ gmail.com

Saturday, December 01, 2007

Blender object alignment scripts

Here is the link to the simple objects alignment scripts that I wrote.

http://www.capitolacomputing.com/blender/scripts/align_scripts.zip

Unlike the method discussed in the below link, which seemed to center the location between objects, my scripts align the objects to the last object selected:


http://wiki.blender.org/index.php/FAQ/Modelling/Mesh#How_do_I_align_objects_on_specific_axis.3F


How to install

1. Unzip and copy these three scripts to "./blender/scripts" directory under your Blender installation.
For example, on MacOS, if you install Blender under /Application, the directory may be:
/Applications/blender-2.44-OSX-10.3-py2.3-powerpc/blender.app/Contents/MacOS/.blender/scripts

If you are using MS Windows, you may need to download the zipped version of Blender that contains ".blender/script" folder instead of using the installer to install Blender.

2. Display "Scripts Window" by selecting "Scripts Window" in the "Window type" icon at the top left of one of your windows.

3. In Scripts Window, Select "scripts | Update Menus" menu item.
This registers the script under the "Scripts | Object" menu.

4. Verify that "Align x" menu item is displayed under the "Scripts | Object" menu.

How to use
1. Go to the 3D View window.
2. While in Object mode, select multiple objects that you want to align in 3D View.
In selecting, please remember that objects will be aligned to the object that is selected last when the script is run.
3. Go to the Scripts Window.
4. Select "Scripts | Object | Align x " menu item to align x location. Use "Align y" or "Align z" if you want to align y or z locations.

If you have questions, please email me at hideyuki@gmail.com