From BlenderWiki

Jump to: navigation, search

Weekly reports




Useful links:

Git merge vs. rebase -


[GITHUB is not useful for this workflow, but here some links anyways]

Getting Started

Create a new folder, and inside this folder do the following commands. Note it will take more than 10 hours to get over with it.

# getting blender souce code
git svn clone blender
# getting the addons
git svn clone addons
git svn clone addons_contrib

Now the tricky part ... you actually need the addons and addons_contrib inside your blender folder. I'm copying them over and whenever I want to update them, I go and re copy them.

rsync -rv --exclude=.git addons blender/release/scripts/
rsync -rv --exclude=.git addons_contrib blender/release/scripts/

It's important to make sure both folders are ignored by git. So you want to add them in the exclude file. See the ignore/exclude section next.

Optionally you can also get the libraries, though honestly you can simply using svn for that. If you have the lib already somewhere else, all you need is a symlink for it.

For the git folder for the library do (darwin-9.x.universal is what I use in Mac):

# getting the libraries
mkdir lib; cd lib
git svn clone darwin-9.x.universal

Git Ignore/Exclude

This is my blender/.git/info/exclude file


Git Update

To update the svn repository into master, and then into 'otherbranch'

cd blender
git checkout master
git svn rebase
git checkout otherbranch
git rebase master

From time to time you may want to update the addons as well, to do so:

cd addons
git svn rebase
cd ../addons_contrib
git svn rebase
cd ../
rsync -rv --exclude=.git addons blender/release/scripts/
rsync -rv --exclude=.git addons_contrib blender/release/scripts/

And every once in a blue moon you want to update the libs:

cd lib/*/
git svn rebase

Git svn branch

If you have a branch in the svn repository that you want to clone, you can do that after you git svn clone'd the master.

1) Define the new branch in .git/config

[svn-remote "multiview"]
	url =
	fetch = :refs/remotes/git-svn-multiview

2) Import the SVN branch.

cd blender
git svn fetch multiview

Optionally you can fetch only the review where the branch was created:

svn log --stop-on-copy
#read the number of the first commit, in my case 57389
cd blender
git svn fetch multiview -r57389

3) Hook up a local Git branch to the remote branch:

git branch --track multiview git-svn-multiview

4) Checkout and update

cd blender
git checkout multiview
git svn rebase

5) All good! The following is an example of my .git/config

	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
[svn-remote "svn"]
	url =
	fetch = :refs/remotes/git-svn
[svn-remote "multiview"]
	url =
	fetch = :refs/remotes/git-svn-multiview
[branch "multiview"]
	remote = .
	merge = refs/remotes/git-svn-multiview

Git Branch

A script to switch the active branch.

#based on 'crep' script from Campbell Barton
git branch --list | sort > $OUT
# Print text with line numbers
sed = $OUT | sed 'N;s/\n/ /'
echo -n "enter a number to edit > "
read -e LINE
if [ "$LINE" == "" ] ; then
    echo "nothing selected... exiting."
    exit 0
LINE=$LINE"p" # 4 -> 4p - for sed
EDIT=$(cat $OUT | sed -n $LINE) # file to edit
rm $OUT
# Now change the branch
git checkout $EDIT

Happy GIT Terminal

(based on

"I have bash configured to show the git branch in terminal, to avoid the (for me) very common mistake of committing, merging or branching in the wrong branch."

__git_ps1 () 
    local b="$(git symbolic-ref HEAD 2>/dev/null)";
    if [ -n "$b" ]; then
        printf "%s " "${b##refs/heads/}";
PS1="\u \[\\033[1;90m\]\$(__git_ps1)\[\\033[0m\]\W\\$ "

Happy GIT Alias

(based on

It requires the __git_ps1 already to be in the .profile

Note the 'gad' alias. This one I use when I want to setup a specific number of jobs (e.g. gad make -j3) or any other command I don't use too often to justify its own alias (e.g. gad ccmake).

function git_any_dir()
    local root="$(git rev-parse --show-toplevel)/../release"
    local branch="$(__git_ps1)"
    local prevdir=$(pwd);
    if [ -d $root/$branch ]; then
        cd $root/$branch
        cd $root/master
    cd $prevdir

Git Vim

Utility to open vim with all the diff and cached files

cached=`git diff --name-only --cached`
diff=`git diff --name-only`
cd $(git rev-parse --show-toplevel)
vim -p ${diff[*]} ${cached[*]}


I had to use git am to move repositories around (see ) This script is to call git am for a sequence of files (NOTE: files folder and "name" hardcoded in the script).

gam () {
    for i in `seq $1 $2`; do
        echo "SVN-PATCH: $i"
        git am $SOURCE/`echo $(printf "%04d" "${i}")`*.patch
        echo "[next]"
        read next

To use I do:

gam 14 19

old stuff

An quick exert about me from Blender Conference 2008 + updates:

Dalai Felinto, who is currently living in Rio de Janeiro, Brazil, has been using Blender since the beginning of his graduate study in Architecture and Urban Studies back in 2003. His participation in the Blender Community includes a paper and a tutorial presented at the 2007 Blender Pro Brazil in Porto Alegre, an image published in a Blender magazine in Brazil, co-hosting of the first Vancouver Blender Workshop in 2008, a work presented with Mike Pan at the 2008 Blender Conference in Amsterdam, two talks at the 2009 Che Blender in Córdoba, Argentina and a number of contributions to Blender code since 2.47.

His past professional experiences with Blender includes the implementation of a dome rendering mode for the Blender Game Engine sponsored by the art school SAT: Society for Arts and Technology of Montreal in 2009, a 3 month job experience as game developer and technical artist for the Entertainment Arts Research's production of a third person action thriller game (Twilight22) and a two month production as a digital artist for the Fisheries Center at the University of British Columbia, Canada, for a 7 minute long digital documentary about the life in Chesapeake Bay.

He's currently involved with a marine ecosystem visualization project at the University of British Columbia in Canada using and developing the Blender Game Engine as an interactive tool.

Tex Face :: Replacement

read about this proposal on:

Dome Offline Rendering Thoughts

moved to:

Complement SDNA

  • Notes about pointers

When adding pointers as structure elements there is one more step you need to do. All pointers are stored in the Blender files with their original address. When the file is loaded, Blender needs to readdress the pointer to the new address of the element. This happens in the readfile.c.

Therefore there is three functions you may need to change to set your pointer. As an example if you want to add an actuator (they are part of the object global list), you you need to edit the readfile.c in three parts:

  • In expand_object() do a expand_doit()
  • In lib_link_object() you do a newlibadr_us()
  • In direct_link_object() ???????

And in writefile.c you will need to write the structure for your pointer. Find the right write_function (eg write_actuators) and call properly writestruct();

For more information check the Blender Architecture.

Blender Conference Architecture Round Table Minute draft

Right now I will write here the minutes of the Blender for Architecture Round Table (This still is a rough, I will clean this later)

Milanov – Architecture

How we can improve Blender to “make the 1st 3D Open Source application”. -a tool not only for presentation, but a project tool

-3d sketchs from the beggining. -sections

Precision (more than 32 bits float precision) Repetition / modules

[Blender -a // playback animation] - curiosity, off-topic but awesome

Offset / trim / extend cross sections Shell

IGES – Nurbs format

FEATURES / ISSUES: -exporter

DXF – Drawing Exchange Format fbx nurbs formats (??) [.x3d .DAE (Collada)] - my addition

Photo matching system (e.g. SketchUp PhotoMatch)

-measuring, summed length values -uvmap, extending the current UV system for simple tasks as paint an UV based in the neighbor faces). -snapping(thanks theeth), more snaps(e.g. center, ...) -precision – render merging problems (when the distance is too small for some distances it results in imprevisible results).

APPENDIX 01 – CAD Commands: (These are my personal list of most required cad commands. I created it to provide a feature request list to the project Archimedes).

It's interesting to see that the only commands Blender can't do were cited in the roundtable. They are: Offset, Distance, Fillet, Trim, Extend.


_____line _____circle =====offset _____polyline _____move _____copy _____mirror _____rotate _____scale _____explode _____match properties _____block _____break =====distance _____scale _____divide =====fillet =====trim =====extend _____arc _____stretch

_____boundary (bo) _____align (al) _____draworder (dr) _____pedit (pe) _____write block (w) _____insert raster image _____paperspace

BGE develop meeting notes

Blender Conference 2008 - 01 – Blender Game Engine future

Blender Game Engine Web Plugin

The web plugin was abandoned since 200????. Recently in this year we have some developers trying to ressucite it to the most diferent platforms. Until now the new plugin is working only for unix systems.

- no bad level calls in 2.50 rewrite

The trend (in Apricot) is to implement all Blender features (Constraints, Drivers, …) in BGE. However there is no budget, no payed BGE developer. Things are changing though.

game engine as a plugin?

Tree data and memory managed to Blender interface converted to BGE objects. This is fine when BGE owrk inside Blender. However outside Blender it doesn't work fine (pointers present risk in memory assignment).

BGE use part of Blender code (IPO, Bone structure) licensing is an issue. Option: separate the data and the code. The game can be released as a blendfile cryptografed and the Game Player (i.e. BlenderPlayer).

WebPlugin Blender Game Engine.

security problem. Python problems. Differences of security levels/issues in network applications or local ones. It is not desired to associate Blender name with the risk of insecure web applications. It is needed a company willing to support the plugin development to stick on that.

SandBoxing issues Blender sand boxing bad python calls

A company should show progress: - Huge companies: Google, Nvidia, IBM - documentation - support maintaince / bugs, features, … It is a lot of work for the company and for the Blender Foundation. Reviewing patches developed for third parts isn't so easy (or exciting)

ISSUES: trusty, capacity rely

UTF8 and complex-scripting

State of Text Rendering

Unicode and "character encodings"

UTF-8 and Latin-1: The Leaning Tower of Babel

Random Notes

  • ASCII is back-supported in pretty much all the possible encodings. For example, ascii can be considered as a sub-set of UTF8.

Unicode range:

0000 - 007F - ascii 0080 - 00FF - latin1 06XX - arabic FEFX - arabic presentation form

utf8 can use up to 4 bytes to represent the data.

"For slots 160 through 255, UTF-8 uses that number to determine how many following bytes to add in when calculating the numbered Unicode slot being referred to." [1]

Bi-Directional text support

external libraries to use with freetype2:]

(1) expand blf to support bidi (i.e. RTL) There are two problems here. One is to draw the text, and the second is to handle editing.

It's impossible to implement editing of bidi without having blf drawing it properly. Thus the plan is to first address drawing and then later editing.


(email that showed up in the mailing list) I guess you can't go wrong with harfbuzz-ng on freetype2. After all, that is what's used to render text in Firefox. libass, the SSA subtitle renderer used in VLC and MPlayer, has recently started to support complex and bidi scripts using harfbuzz and fribidi on top of freetype2. That resulted in very sophisticated rendering of complex texts. Implementing that turned out to be easier than the developer had thought. [2]

Drawing Complex Scripting

  • note: even after we have bfl handling bidi we can still use the and scripts. they should work either way and they should bring some optimization (given that interface drawing happens all the time).

Editing Complex Scripting

Likely re-using part of the code from the drawing routine.

Unifying utf8 with ascii and removing latin1

My proposal is to merge ascii and utf8 in the GHOST_System* files (they all lead to GHOST_EventKey.h). Also any input (keys, clipboard, ...) should be converted to utf8. (for Text Editor convert to utf8? or pops up an warning: File with non-supported encoding. [ ] cancel opening file [ ] convert file to utf8)

The one part we will still need latin1 is the filepath checking. Specially in windows we have a lot of filepaths using non-utf8 encoding (latin1 seems to be the default there). We would need to convert the typed in path to latin1 as a fallback when the utf8 typed path doesn't exist. Or we find native OS calls to handle that.

Miscellaneous Programming Stuff

Campbell Barton great collection of scripts - [3] I use crep all the time.

building and piping

python2.7 scons/ -j1 2>&1 | tee out.txt


svn tips

[b]make a file executable[/b]: svn propset svn:executable ON [filename]

[b]make externals[/b]: svn propset svn:externals -F [list of externalsfilename]

[b]commit with log inline[/b]: svn commit --message="log message can be multi-line"

vim tips

[b]ga[/b]: reads a unicode char (the hexacode can be used with "\uXXXX" in python.

[b]Ctrl+V uXXXX[/b]: insert a unicode in insert mode

pydocs update

# my blender source is in ~/blender/bf and my release build in ~/blender/release
# needs sphinx first:
#sudo easy_install -U Sphinx
cd ~/blender/bf
# apply bpy context patch
patch -p0 <<END
Index: doc/python_api/
--- doc/python_api/	(revision 43647)
+++ doc/python_api/	(working copy)
@@ -61,7 +61,9 @@
 if 1:
     # full build
+    "bpy.context"
+    )
     FILTER_BPY_OPS = None
# generate the raw files
~/blender/release/bin/ --background -noaudio --python doc/python_api/
# generate the html files
cd doc/python_api
sphinx-build sphinx-in sphinx-out
# launch the webbrowser
open sphinx-out/contents.html
# revert source
svn revert


Sometimes I need to check the changes in a branch against the original code in trunk. `svn diff` will only tell me part of the story (what I changed from last commit to the branch).

`ddiff Ketsji/KX_Dome.cpp` will run a diff -u comparing the branch KX_Dome.cpp with trunk's one. It assumes you have blender code in ~/blender/bf It can work with meld as well, but in OSX I can't get meld to work so whatever :)

import sys, os
HOME = os.getenv('USERPROFILE') or os.getenv('HOME')
BLENDERSOURCE = os.path.abspath(os.path.join(HOME, 'blender', 'bf'))
file = sys.argv[1]
basepath = os.path.dirname(file)
filepath = os.path.basename(file)
path = os.popen('cat %s | grep branches' % (os.path.join(basepath, '.svn', 'all-wcprops'))).read().split()[0]
path_parts = path.split(os.sep)
branch_id = path_parts.index('branches')
trunk_path = os.sep.join(str(n) for n in path_parts[branch_id+2:])
trunk_path = os.path.join(BLENDERSOURCE, trunk_path, filepath)
# ignore the ID line in Blender code (the $id:....$)
# it may need a better regex but this works for now
svn_id_regex = '[$]Id:'
os.system("diff -u --ignore-matching-lines=%s \"%s\" \"%s\"" % (svn_id_regex, trunk_path, file))

Arabic to UTF8

Script based on the original take by Yousef Harfoush -

It takes an arabic po file file and flip and convert the characters to the utf8 char corresponding to the right shape for its position. It runs with Python 3.2 `python3.2 ar.po []`

#coding: utf-8
import sys
import os
alfmd = ["ﺁ","ﺁ","ﺂ","ﺂ"]
alfhz = ["ﺃ","ﺃ","ﺄ","ﺄ"]
wowhz = ["ﺅ","ﺅ","ﺆ","ﺆ"]
alfxr = ["ﺇ","ﺇ","ﺈ","ﺈ"]
hamzk = ["ﺉ","ﺋ","ﺌ","ﺊ"]
alfff = ["ﺍ","ﺍ","ﺎ","ﺎ"]
baaaa = ["ﺏ","ﺑ","ﺒ","ﺐ"]
tamrb = ["ﺓ","ﺓ","ﺔ","ﺔ"]
taaaa = ["ﺕ","ﺗ","ﺘ","ﺖ"]
thaaa = ["ﺙ","ﺛ","ﺜ","ﺚ"]
geeem = ["ﺝ","ﺟ","ﺠ","ﺞ"]
haaaa = ["ﺡ","ﺣ","ﺤ","ﺢ"]
khaaa = ["ﺥ","ﺧ","ﺨ","ﺦ"]
daaal = ["ﺩ","ﺩ","ﺪ","ﺪ"]
thaal = ["ﺫ","ﺫ","ﺬ","ﺬ"]
raaaa = ["ﺭ","ﺭ","ﺮ","ﺮ"]
zaaai = ["ﺯ","ﺯ","ﺰ","ﺰ"]
seeen = ["ﺱ","ﺳ","ﺴ","ﺲ"]
sheen = ["ﺵ","ﺷ","ﺸ","ﺶ"]
saaad = ["ﺹ","ﺻ","ﺼ","ﺺ"]
daaad = ["ﺽ","ﺿ","ﻀ","ﺾ"]
taaah = ["ﻁ","ﻃ","ﻄ","ﻂ"]
daaah = ["ﻅ","ﻇ","ﻈ","ﻆ"]
aayen = ["ﻉ","ﻋ","ﻌ","ﻊ"]
gayen = ["ﻍ","ﻏ","ﻐ","ﻎ"]
faaaa = ["ﻑ","ﻓ","ﻔ","ﻒ"]
qaaaf = ["ﻕ","ﻗ","ﻘ","ﻖ"]
kaaaf = ["ﻙ","ﻛ","ﻜ","ﻚ"]
laaam = ["ﻝ","ﻟ","ﻠ","ﻞ"]
meeem = ["ﻡ","ﻣ","ﻤ","ﻢ"]
nooon = ["ﻥ","ﻧ","ﻨ","ﻦ"]
hhhhh = ["ﻩ","ﻫ","ﻬ","ﻪ"]
wowww = ["ﻭ","ﻭ","ﻮ","ﻮ"]
yaamd = ["ﻯ","ﻯ","ﻰ","ﻰ"]
yaaaa = ["ﻱ","ﻳ","ﻴ","ﻲ"]
laamd = ["ﻵ","ﻵ","ﻶ","ﻶ"]
laahz = ["ﻷ","ﻷ","ﻸ","ﻸ"]
laaxr = ["ﻹ","ﻹ","ﻺ","ﻺ"]
laaaa = ["ﻻ","ﻻ","ﻼ","ﻼ"]
numbers ="0123456789٠١٢٣٤٥٦٧٨٩"#defining numbers
unicodec ="ﺁﺁﺂﺂﺃﺃﺄﺄﺅﺅﺆﺆﺇﺇﺈﺈﺉﺋﺌﺊﺍﺍﺎﺎﺏﺑﺒﺐﺓﺓﺔﺔﺕﺗﺘﺖﺙﺛﺜﺚﺝﺟﺠﺞﺡﺣﺤﺢﺥﺧﺨﺦﺩﺩﺪﺪﺫﺫﺬﺬﺭﺭﺮﺮﺯﺯﺰﺰﺱﺳﺴﺲﺵﺷﺸﺶﺹﺻﺼﺺﺽﺿﻀﺾﻁﻃﻄﻂﻅﻇﻈﻆﻉﻋﻌﻊﻍﻏﻐﻎﻑﻓﻔﻒﻕﻗﻘﻖﻙﻛﻜﻚﻝﻟﻠﻞﻡﻣﻤﻢﻥﻧﻨﻦﻩﻫﻬﻪﻭﻭﻮﻮﻯﻯﻰﻰﻱﻳﻴﻲﻵﻵﻶﻶﻷﻷﻸﻸﻹﻹﻺﻺﻻﻻﻼﻼ"#defining arabic unicodec chars
left = "ـئظشسيبلتنمكطضصثقفغعهخحج"				#defining letters that can connect from the left
right = "ـئؤرلالآىآةوزظشسيبللأاأتنمكطضصثقفغعهخحجدذلإإ"#defining letters that can connect from the right
arabic ="ًٌٍَُِّْْئءؤرلاىةوزظشسيبلاتنمكطضصثقفغعهخحجدذْلآآلأأـلإإ،؟"#defining all arabic letters + harakat + symbols
harakat ="ًٌٍَُِّْْ"		#defining the harakat
sym ="ًٌٍَُِّـ.،؟ @#$%^&*-+|\/=~(){}ْ,"	#defining other symbols
def ProcessInput(input):
    '''main function, the code is not self-explanatory. It requires understanding of arabic alphabet (which is pretty cool by the way)'''
    phrase = ""
    #process each letter, submit it to tests and then add it to the output string
    # we can't do a for loop because we need to change 'g' inside the loop
    g = 0
    while g < ln: 
        b=a=1 #ignoring/discarding the harakat
        # see how many chars I need to skip to get the next
        # non-harakat char in the left (a) or the right(b)
        while g-b >= 0 and x[g-b] in harakat: b+=1
        while g+a < ln and x[g+a] in harakat: a+=1
        # if char can connect to left and there is a char after
        # and it can connect to the right:
        if x[g] in left and g+a < ln and x[g+a] in right:
            if x[g] in right and g-b >= 0 and x[g-b] in left:
                pos = 2 #midle
                pos = 1 #initial
            if x[g] in right and g-b >= 0 and x[g-b] in left:
                pos = 3 #final
                pos = 0 #isolated
        # find what char to aggregate to the phrase based on the input and its
        # position in the word.
        chr = ""
        if x[g]=="\n": {} #if this char is a new line, go to add new line def
        elif x[g]=="\r": {} #if this char is carriage return, skip it.
        elif x[g]=="{": chr="}" #dealing with parenthesis
        elif x[g]=="}": chr="{"
        elif x[g]=="(": chr=")"
        elif x[g]==")": chr="("
        elif x[g]=="ء": chr="ﺀ"
        elif x[g]=="آ": chr=alfmd[pos] #dealing with letters, output each letter with its right position
        elif x[g]=="أ": chr=alfhz[pos]
        elif x[g]=="ؤ": chr=wowhz[pos]
        elif x[g]=="إ": chr=alfxr[pos]
        elif x[g]=="ئ": chr=hamzk[pos]
        elif x[g]=="ا": chr=alfff[pos]
        elif x[g]=="ب": chr=baaaa[pos]
        elif x[g]=="ة": chr=tamrb[pos]
        elif x[g]=="ت": chr=taaaa[pos]
        elif x[g]=="ث": chr=thaaa[pos]
        elif x[g]=="ج": chr=geeem[pos]
        elif x[g]=="ح": chr=haaaa[pos]
        elif x[g]=="خ": chr=khaaa[pos]
        elif x[g]=="د": chr=daaal[pos]
        elif x[g]=="ذ": chr=thaal[pos]
        elif x[g]=="ر": chr=raaaa[pos]
        elif x[g]=="ز": chr=zaaai[pos]
        elif x[g]=="س": chr=seeen[pos]
        elif x[g]=="ش": chr=sheen[pos]
        elif x[g]=="ص": chr=saaad[pos]
        elif x[g]=="ض": chr=daaad[pos]
        elif x[g]=="ط": chr=taaah[pos]
        elif x[g]=="ظ": chr=daaah[pos]
        elif x[g]=="ع": chr=aayen[pos]
        elif x[g]=="غ": chr=gayen[pos]
        elif x[g]=="ف": chr=faaaa[pos]
        elif x[g]=="ق": chr=qaaaf[pos]
        elif x[g]=="ك": chr=kaaaf[pos]
        elif x[g]=="ل": #dealing with (la combination
            if ln == g:
            elif x[g]=="ا": chr=laaaa[pos]
            elif x[g]=="أ": chr=laahz[pos]
            elif x[g]=="إ": chr=laaxr[pos]
            elif x[g]=="آ": chr=laamd[pos]
        elif x[g]=="م": chr=meeem[pos]
        elif x[g]=="ن": chr=nooon[pos]
        elif x[g]=="ه": chr=hhhhh[pos]
        elif x[g]=="و": chr=wowww[pos]
        elif x[g]=="ى": chr=yaamd[pos]
        elif x[g]=="ي": chr=yaaaa[pos]
        elif x[g]=="لآ": chr=laamd[pos]
        elif x[g]=="لأ": chr=laahz[pos]
        elif x[g]=="لإ": chr=laaxr[pos]
        elif x[g]=="لا": chr=laaaa[pos]
        elif x[g] in sym: chr=x[g] #if the char is a symbol, add it
        elif x[g] in unicodec: chr=x[g] #if the char is an arabic reversed letter, reverse it back!
        # advance to the next char
        g += 1
        # add the char before the previous one
        hrase = chr+phrase
    return phrase
def Start(fileR, fileW):
    '''open the .po file and do a special reverse in the msgstr lines'''
    fileR = open(fileR, "r",-1, "utf-8")
    fileW = open(fileW, "w",-1, "utf-8")
    inside_msgstr = False
    inside_header = True
    for line in fileR:
        if inside_header:
            if line == "\n": inside_header = False
            if line[:6] == ("msgstr"):
                    word = line.split("\"")
                    strng = word[1]
                    rslt = ""
                    if strng:
                        rslt = str(ProcessInput(strng))
                    fileW.write("msgstr \"" + rslt + "\"\n")
                    inside_msgstr = True
            elif inside_msgstr:
                word = line.split("\"")
                if len(word) > 1:
                    strng = word[1]
                    rslt = str(ProcessInput(strng))
                    fileW.write("\"" + rslt + "\"\n")
                    inside_msgstr = False
                inside_msgstr = False
if __name__ == "__main__":
    #argument parsing
    if len(sys.argv) != 2 and len(sys.argv) != 3:
        print("Error: Missing arguments. Use: `python ar.po [ar_done.po]`")
    if file_input[-3:] != ".po":
        print("Error: Wrong file format. Use: `python ar.po [ar_done.po]`")
    # the last parameter is optional
    if len(sys.argv) == 2:
        file_output = "%s_done.po" % file_input[:-3]
        file_output = os.path.abspath(sys.argv[2])
    # parse the file
    Start(file_input, file_output)

Windows Blender Build 1

Batch script to update and build Blender in Windows with MSVC+Scons. You need Python installed and matching the architecture you are to build for (i.e. Python32 bits for Windows32 bits and Python64 for Windows 64). As of the time of writing Python 2.XX is the only supported series.

You also need SlikSvn for your version of Python (it's a Python SVN client, really nice)

To build for 64 bits you need to use those lines instead of the ones in the script: Set USERCONFIG=%BLENDER%\ call %MSVC% amd64

:requires SlikSvn and MSVC 2008 with command prompt
@echo off
Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
Set SVN="C:\Program Files\SlikSvn\bin\svn.exe"
Set PYTHON="C:\Python27\python.exe"
Set BLENDER=C:\Blender\bf
REM the number of processors to use to render
echo Launching MSVC
call %MSVC% x86
chdir %BLENDER%
echo Updating Blender
%SVN% --accept postpone update
echo Removing old Blender build
rmdir /s/q "..\install_fun"
echo Building Blender
echo Congratulations for updating Blender

Windows Blender Build 2: build + update internal SVN

This script is a .bat file to update Blender, build it, and update (but not commit) my internal production svn. It requires MSVC, python (2.6 or 2.7), SlikSVN.

The paths are defined in the first lines of the script. CUPCAKE is my internal svn repository. Also the number of threads to use (8) is hardcoded after the -j argument in the scons line.

:requires SlikSvn and MSVC 2008 with command prompt
@echo off
Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
Set SVN="C:\Program Files\SlikSvn\bin\svn.exe"
Set PYTHON="C:\Python26\python.exe"
Set BLENDER=C:\Blender\BF_25\bf
REM the number of processors to use to render
Set CUPCAKE=C:\CupCake
echo Launching MSVC
call %MSVC% amd64
chdir %BLENDER%
REM HACK goto noupdate
echo Updating Blender
%SVN% --accept postpone update
set INPUT=
set /P INPUT=Do you want to proceed? [y/n] %=%
if "%INPUT%"=="n" goto exit
if "%INPUT%"=="i" goto install
echo Removing old Blender build
rmdir /s/q "..\install"
echo Building Blender
echo Copying build files to svn folder
%SVN% revert --depth infinity %CUPCAKEBINARY%
rmdir /s/q %CUPCAKEBINARY%
xcopy /y/s/q %BLENDER%\..\install\blender25-win64-vc %CUPCAKEBINARY%
set INPUT=
set /P INPUT=Do you want to update your local svn? [y/n] %=%
if "%INPUT%"=="n" goto exit
echo Updating svn folder
echo Congratulations for updating Blender

Windows Blender Build 3: build + random splash screen

This script is a .bat file to update Blender and build Blender with a different Splash Screen every time. It requires MSVC, python (2.6 or 2.7), SlikSVN.

Splash screens can be generated with the script present in Blender source code. I'm actually using a patched version of Blender's to generate datatoc for all images in a folder.

:requires SlikSvn and MSVC 2008 with command prompt
@echo off
REM general folder settings
Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
Set SVN="C:\Program Files\SlikSvn\bin\svn.exe"
Set PYTHON="C:\Python26\python.exe"
Set BLENDER=C:\Blender\bf
REM folder with splash screens converted with
Set SPLASHFOLDER=C:\Blender\splashes\datatoc
REM the number of processors to use to render
:: ::::::::::::::::::::::::::::::::::::::::::::::::::: ::
:: That should be all, no need to setup anything else
:: ::::::::::::::::::::::::::::::::::::::::::::::::::: ::
echo Launching MSVC
call %MSVC% amd64
:: Do you want to update the source?
set INPUT=
set /P INPUT=Do you want to update Blender? [y/n] %=%
if "%INPUT%"=="n" goto install
chdir %BLENDER%
echo Updating Blender
%SVN% --accept postpone update
set INPUT=
set /P INPUT=Do you want to proceed? [y/n] %=%
if "%INPUT%"=="n" goto exit
if "%INPUT%"=="i" goto install
:: Replace the Splash Screen
chdir %BLENDER%
echo Replacing the Splash Screen
set count=0
set x=0
setlocal enabledelayedexpansion
::Put all the files into a pseudo-array prefixed with "PIC_"
for /r "%SPLASHFOLDER%" %%a in (*.png.c) do (
    set PIC_!count!=%%~a
    set /a count+=1
REM Use the 'modulo' function to get a usable value from system variable %random%
set /a x="%RANDOM% %% count"
REM Pull the relevant item out of the "PIC_" 'array'
set chosen=!PIC_%x%!
echo: New Splash Screen :: %chosen:~0,-2%
Set BLENDERSPLASH=%BLENDER%\source\blender\editors\datafiles\splash.png.c
copy /y "%chosen%" "%BLENDERSPLASH%"
@echo off
:: Cleaning up the installation directory
echo Removing old Blender build
rmdir /s/q "..\install"
echo Building Blender
echo Congratulations for updating Blender with a fantastic new Splash Screen ;)

Patched to facilitate creating multiple splash screens from a folder.

# -*- coding: utf-8 -*-
# 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
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# The Original Code is Copyright (C) 2009 Blender Foundation.
# All rights reserved.
# <pep8 compliant>
import sys
import os
def createDatatoc(filename):
        fpin = open(filename, "rb")
        sys.stdout.write("Unable to open input %s\n" % sys.argv[1])
        sys.stdout.write("Trying folder now%s\n" % sys.argv[1])
        sys.exit(1), os.SEEK_END)
    size = fpin.tell()
    if filename[0:2] == "." + os.sep:
        filename = filename[2:]
    cname = filename + ".c"
    sys.stdout.write("Making C file <%s>\n" % cname)
    filename = filename.split("/")[-1].split("\\")[-1]
    filename = filename.replace(".", "_")
        fpout = open(cname, "w")
        sys.stdout.write("Unable to open output %s\n" % cname)
    fpout.write("/* DataToC output of file <%s> */\n\n" % filename)
    fpout.write("int datatoc_%s_size= %d;\n" % ("splash_png", size))
    fpout.write("char datatoc_%s[]= {\n" % "splash_png")
    while size > 0:
        size -= 1
        if size % 32 == 31:
        fpout.write("%3d," % ord(
    fpout.write("\n  0};\n\n")
if __name__ == '__main__':
    if len(sys.argv) < 2:
        sys.stdout.write("Usage: datatoc <data_file>\n")
    filename = sys.argv[1]
    if not os.path.isdir(filename):
        for file in os.listdir(filename):
            if os.path.isdir(file): continue

building bpy for OSX

Blenderplayer has to be built with the Framework Python (WITH_PYTHON_FRAMEWORK) has to be built independently (WITH_PYTHON_MODULE)

This works fine, however the user has to install Python in her Mac. To make this portable you need to change the linkage from the Frameworks to a local folder.

I'm still struggling with it, so for now I'll only list the commands.

Patch for CMake:


To change the linkage:


install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.2/Python @loader_path/2.63/Frameworks/Python

To check the linkage:


otool -L

To change the id:


install_name_tool -id Python Python

jensverwiebe: but not static, i bundle the framework, static gives again thread error, but no prob [1:17pm] jensverwiebe: [1:17pm] jensverwiebe: the 2.63 folder must be beside .so [1:21pm] jensverwiebe: how it works: [1:21pm] jensverwiebe: build as setup in cmake against py framework [1:22pm] jensverwiebe: add from lib the modules to the 2.63 folder + the framework lib out of framework

Bonus: lipo -info foo.a lipo just specialized on architecture handling: glue, thin, extract, show ...


/bjam -j8 toolset=darwin link=static cxxflags='-fvisibility=hidden -fvisibility-inlines-hidden -fpic' threading=multi architecture=x86 address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 stage install

project-config.jam after the ./boostrap run

bison -dv -p osl -o oslgram.cpp oslgram.y

Python Debug



Rename all 0001Right.jpg images to 0001_R,jpg

for i in *Right.jpg; do j=`echo $i | sed 's/Right/_R/g'`; mv $i $j; done

Create MultiView OpenEXR files:

for L in OpenEXR_Left/*; do R=`echo $L | sed 's/_L\./_R./g' | sed 's/Left/Right/g'`; MV=`echo $L | sed 's/_Left/_MultiView/g' | sed 's/_L\././g'`; exrmultiview left $L right $R $MV; done

Reverse array and increase and copy files:

array=();for i in *;do array=( "$i" "${array[@]}");done; c=1; for i in ${array[@]}; do k="../preview_right_reverse/"`echo $(printf "%.4d" "$c")`".png";c=`echo $(($c+1))`; echo "cp "$i" "$k""; cp `echo "$i"` `echo "$k"`;done

Rename batch:

for i in `seq 4 62`; do j=`echo $(printf "%02d" "$((i-2))")`;mv Fig04-`echo $(printf "%02d" "$i")`.tif Fig04-$j.tif;done

Convert all files to tif:

for i in *.png; do j=`echo $i | sed 's/png/tif/g'`; convert $i $j; done

Remove duplicates:

cat MYFILES | sort -u > MY_NEWFILES

Convert tabs to space:

for i in *.py; do perl -e '($_ = join "",<>) =~ s/(\t)/    /g; print;' -i < $i > /tmp/abc; mv /tmp/abc $i; done

Convert tabs to space 2:

for i in `find * -name *.py`; do expand $i > /tmp/abc; mv /tmp/abc $i; done

Remove trailing spaces:

for i in `find * -name *.py`; do sed -i '' -e's/[[:space:]]*$//' $i; done

Split a branch into individual commits per file:

for i in `git diff origin/master origin/pep8ized --name-only`; do git show origin/pep8ized:$i > $i; git add $i; git commit -m $i;done

Convert all files from python 2 to python 3

for i in `find . -name "*.py" | grep -v venv`; do 2to3-3.5 -w $i; done



rebase an svn folder:

for f in `find . -name '*' -print|grep entries`; do sed -i '' -e's/https:\/\/iml-gfx/http:\/\/' $f; done

create external:

svn propset svn:externals 'database' .


replace all instances of TRUE by 1 not including ifdef of _TRUE

for i in `cat FILES`;do sed -i '/ifdef\ /b; /_TRUE/b; s/TRUE/1/g' $i;done

swap the first with the second field in a csv file


change python code for my files

for f in `cat ~/tmp/FILES`; do sed -i 's/os.path.join\((.*)\)/"\/".join(\1)/' $f; done


RTSP Server

vlc -vvv your_file.avi --sout "#rtp{dst=dest_adress,port=1234,sdp=rtsp://your_ip_adress:8080/test.sdp}"

RTSP Client

vlc -vvv rtsp://your_ip_address:8080/test.sdp

RTSP Building Instructions

--enable-network --enable-protocol=tcp --enable-demuxer=rtsp --enable-decoder=h264


Update my copy of manual: rsync -rvu --exclude=.doctrees html/

To start the RST server: instantRst -f /home/guest/blender/git/blender-manual/manual/render/workflows/multiview.rst -b google-chrome

Linux VM memory issues

Checks current swap space by running free command (It must be around 10GB.). Checks the swap partition

sudo fdisk -l 
/dev/hda8 none swap sw 0 0

Make swap space and enable it.

sudo swapoff -a 
sudo /sbin/mkswap /dev/hda8 
sudo swapon -a

If your swap disk size is not enough you would like to create swap file and use it.

Create swap file.

sudo fallocate -l 10g /mnt/10GB.swap 
sudo chmod 600 /mnt/10GB.swap


sudo dd if=/dev/zero of=/mnt/10GB.swap bs=1024 count=10485760
sudo chmod 600 /mnt/10GB.swap

Mount swap file.

sudo mkswap /mnt/10GB.swap

Enable swap file.

sudo swapon /mnt/10GB.swap

SVN Frontend for GIT


Add the following in the Tools > Options > Startup

break __asan_report_error break AsanCheckFailed break __ubsan_handle_out_of_bounds


Unfreed memory: uncomment //#define DEBUG_BACKTRACE in mallocn_guarded_impl.c, and make a debug build

Cleanup Files

find * -name *.blend1 | xargs -I{} cp "{}"

Image Magick

convert EAST_0001_R.jpg WEST_0001_R.jpg ZENITH_0001_R.jpg NADIR_0001_R.jpg NORTH_0001_R.jpg SOUTH_0001_R.jpg EAST_0001_L.jpg WEST_0001_L.jpg ZENITH_0001_L.jpg NADIR_0001_L.jpg NORTH_0001_L.jpg SOUTH_0001_L.jpg +append output.jpg

MEM Debug Blender

diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 76b7e072321..387e9d419d2 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -52,13 +52,13 @@
  * but this introduces some overhead to memory header and makes
  * things slower a bit, so better to keep disabled by default
 /* Only for debugging:
  * lets you count the allocations so as to find the allocator of unfreed memory
  * in situations where the leak is predictable */
 /* Only for debugging:
  * defining DEBUG_THREADS will enable check whether memory manager
@@ -76,7 +76,7 @@
  * memory block was allocated and print this trace for all
  * unfreed blocks.
 #  define BACKTRACE_SIZE 100
@@ -84,7 +84,7 @@
    /* set this to the value that isn't being freed */
 static int _mallocn_count = 0;
 /* breakpoint here */