Thursday, September 1, 2011

6 Blender Terminal One Liners That Will Save You a Lot of Time

I've been messing around with the command line recently and I've figured out a few cool terminal commands for Blender. Using the command line can save you hours of work (seriously!). But before we start let me show you some basic terminal commands. By the way I'm using ubuntu 11.04 but this will work on all linux versions.
Note: Do not type the $ in front of the commands I am showing you( i.e. $ blah blah blah) this is only to show you that you are logged in as a normal user and not the as root user.
First of all you'll have to find the terminal, its located in Applications > Accessories > Terminal

So once you have started up your terminal you'll see something like this(I customized mine):
You will notice that to the in front of your typing cursor it will say "(your user name)@(your computer name) ~" This is saying that you are currently logged in (as your user name)and you are at your home folder(~).
To start you will need to know how to navigate to a folder(aka. a directory)
The basic idea of the cd (call directory) command, is:
$ cd directory name
So to navigate to your Desktop, type:
$ cd Desktop
To go up a directory, type:
$ cd ..
Note: Linux is case sensitive so make sure you capitalize the "D" in Desktop.
The other command I will teach you today, is the ls command. Again the basic syntax:
$ ls
(Not to complicated :) )
To also view the size of the files and folders, type:
$ ls -l

There are many more commands, but here is a link to get you started with the basics:
Now for the blender stuff.
If you want to open a blender file that is your current directory, or you don't want to go through the trouble of finding it, navigate to the folder using cd(if you are not already in it). Then type:
$ blender file name.blend
This will open blender with your file automatically loaded.
If you want to open blender without borders(which means full screen):
$ blender -W
If you have a specific size and/or location:
blender -p 40 40 800 600
This will set the lower left corner at 40(along the x axis), 40 (along the y axis), width to 800 and height to 600(Respectively as stated in the code above).
And now for a whopper(but a goodie):
$ for f in *.blend ; do blender -b "$f" -o //render/`echo "$f" | cut -d'.' -f1`-###.png -t 64 -a; done
Here's whats going on:
for every file in the current directory:
load the the blender file (whatever f is)in the background - without the UI(-b)
now set the output of the file to /whatever directory we are in/render/ and sets the name of each frame to the name of blender file + the frame number(those pound signs: ###)
next it sets the number of threads to 64(maximum)(to speed up the render)(-t)
and finally renders an animation(from the start of the file to the end of the file)(-a)
then loops through for the next file until the end

I run this one every night before bed and in the morning Abracadabra Alakazam *** Applause ***, its rendered all my blender files.

Say you have a folder full of blender files, but there are a bunch of .blend1 files that you don't want distracting you(so you are going to delete them):
find . -name "*.blend1" -exec rm "{}" \;
So it finds all the .blend1(-name "*.blend") files in the current directory(.), and removes them(rm).

And now last but not least, say you rendered a string of images that were too large, but you didn't want to have to go in gimp and resize each one by hand:
mogrify -resize 300x300\> *.jpg
Which will resize every JPG file in the current directory to a height of 300px.
Note: This command uses Image Magick

There are more blender commands that you can learn by typing:
$ info blender

I hope you learned something from this tutorial. If you have any problems or ideas please comment below and I will respond as quickly as I can.

No comments:

Post a Comment