Member-only story
How to programmatically render with Blender?
As you may know, I am developing flashcard games for programmers called Summon The JSON. Since that said, I had to create a lot of graphics for my store, and social media. One way to do it is to take photos. But there is only that much photos you can take. And also, it is hard to take photos in all sizes of all decks, and keep the same quality.
For some time I have used Blender to render some of presentation illustrations for my deck. But what was missing was a way to automate it. So that quality is consistent for all current decks (JavaScript, PHP, C#, C++, React, PHP and Python so far) and decks I plan to publish.
Today I discovered it is possible to automate Blender with batch and a little bit of Python!
Textures
Automating texture is pretty straight forward. You can actually set a relative path to a texture in a Blender file. Than Blender will fetch texture from that file. What I did was to replace with batch textures for every deck automatically:
robocopy “!deckpath!” tmp /njh /njs /ndl /nc /ns
And execute rendering from command line that is pretty simple:
blender -b generator.blend -f 0 -o //render
The result: