Python scripts

Python scripts

Those scripts should work as expected:

  1. Process one model from the command line
  2. Automatic BakeMyScan tests

Those don’t work at the moment and will be fixed soon (they are here for me to fix them, so don’t even bother reading them):

  1. Process multiple models
  2. Process a Sketchfab collection
  3. Import processed models in a grid layout

And others will come!

0 - Before getting started

Get ready to use the command line

These scripts are still unstable, and might not work in some cases. Although they should work, proceed with caution!

First make sure that you followed the related setup instructions, and navigate with your command prompt into the directory containing the scripts.

If you do not know what a command prompt is (don’t worry, we’ve all been there!), I’d suggest getting familiar with it first: you’ll find some example instructions for Windows here and for MacOS there. If you use linux, I’ll assume that you know how to use a terminal ;)

Finally, make sure to replace “blender” in every command by the correct executable. It might be “blender”, “/path/to/blender/blender.exe”, or “blender.exe” if you are using the powershell on Windows. I’ll leave that up to you to find your way!

If something fails

If some of the scripts fail, you can try to:

  1. check the terminal output to try and understand what happened
  2. run the command without -b, which will open blender’s GUI, and look at the blender file to understand what went wrong.

If this still does not work, have a look at the current issues to see if you can relate to something I’m working on or planning to implement, and if you think you found a bug, do not hesitate to open a new issue.

1 - Process one model

The whole process is automated thanks to the scripts/ python script that blender can execute from the command line. Check the script body to understand what happens.


blender -b -P scripts/ -- --help
blender -b -P scripts/ -- IN OUT [-Z] [-M METHOD] [-X TARGET] [-R RESOLUTION] [-c COLOR] [-m METAL] [-r ROUGH] [-g GLOSS] [-a AO] [-n NORMAL] [-d HEIGHT] [-e EMIT] [-o ALPHA]


For instance on my linux computer, all the following commands would be acceptable to process model.obj into model.fbx:

blender -b -P model.obj model.fbx

blender -b -P model.obj model.fbx -Z

blender -b -P model.obj model.fbx -M MMGS -X 0.005

blender -b -P model.obj model.fbx -M INSTANT -X 4000

blender -b -P model.obj model.fbx -M QUADRIFLOW -X 3000

blender -b -P model.obj model.fbx -M MESHLAB -X 500

blender -b -P model.obj model.fbx -M ITERATIVE -X 1000

blender -b -P model.obj model.fbx -M DECIMATE -X 1000

blender -b -P model.obj model.fbx -M NAIVEQUADS -X 0.01

blender -b -P model.obj model.fbx -R 2048 –color albedo.png –normal nm.jpg –metallic metal.tif –roughness rough.jpeg –ao ambientOcc.jpg –displacement heightmap.PNG –emission emit.jpg –opacity alpha.png

2 - Automatic tests

Build Status

I also use a python script to run tests with Travis (see the build history here), in order to validate that I did not break everything while modifying the code, and also to obtain that nice green badge (I hope it’s still green!!).

The script is available here: tests/, and you can launch it on your computer to see if everything happens correctly with:

blender -b -P tests/

Note that the tests depending on external software might fail if they were not configured properly.

3 - Process multiple models

Does not work yet (I still have to… fix stuff)

Really, do not try it yet ;)

To process multiple models, you can use the scripts/batch_processing/ script, which is a wrapper around

The command line syntax is as follows:



Please note that to be matched automatically, the albedo texture file associated with your model must contain “alb” or “col” (case-insensitive) in its name, while the normal texture must contain “nor”. Files called myObject_Albedo.png or COLOR_myObject.jpg will therefore be identified as an albedo map (but not myObject_image.jpg) and texture_norMalS.png as a normal map.

The script will ask you to manually assign albedo and/or normal map textures if it does not find textures with such patterns.

For instance, the following directory structure can be automatically processed:


The command used would be:

python3.5 -i /home/loic/tmp -o /home/loic/lowpoly -p elephants -t 2500 -r 2048


Upon completion (and after having received info similar to the screenshot above), the directory /home/loic/lowpoly should look like so:


IMPORTANT: The last files are the logs from blender, which you can inspect if something went wrong during the transformation to lowpoly, and the list.csv file keeps track of the models previously processed, so that existing models are not overridden when running the script multiple times in a row (to modify problematic models or add new ones for instance).

4 - Process a Sketchfab collection

Does not work anymore either

The documentation below is outdated!!

IMPORTANT: as you can check in the source files, the python scripts only use your Sketchfab email adress and password in the login_to_sketchfab function (found in in order to automatically login to your Sketchfab account from selenium.


python3.5 -u URL -o OUTDIR [-m MAIL] [-p PWD]


To download this stick in /home/loic/tmp:

python3.5 -u -o /home/loic/tmp -m -p mypassword

To download all models from this collection stored in /home/loic/tmp (you will be prompted for your Sketchfab user name and password if you don’t write them in the command):

python3.5 -u -o /home/loic/tmp

Note that the models name, url and license as well as the author name and profile url are dumped to a file in the output directory, to keep track of the objects you downloaded and allow you to give appropriate credit.

Once the downloads are complete, you can then use the script to process your models!

5 - Import processed models

I also wrote a script ( to import the baked models in blender on a grid layout, similar to the one below:


It is used like so:

blender --python -- -i INDIR [-r NUMROWS]


Note that as I did not specify the –background option, a new blender window will open, in which you’ll be able to adjust the grid layout (using for instance Individual origins as pivot point to scale and rotate objects, or Manipulate center points to change the margin).

I would advice you to save the newly (and nicely!) created scene by packing the textures using File -> External data -> Pack all in .blend, which will then allow you to remove the temporary directories and models which were created in the process.