0
$\begingroup$

Rendering without fire when executed from command prompt

In this question, the answer given states that the baked files should be included when rendering using the command line. However, they did not mention how to do so. Any guidance would be appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

As far as I know, and I get this from Command Line Arguments — Blender Manual, there is no way to do this only with command lines. Blender's command line usage is limited to headless rendering and some debugging for developpers.

However, there is the argument -P (uppercase!) which allows you to run a python script. So theoretically, if you have a python script that does the data packing, then saving, then rendering, it might work.

So, considering in my case I am working from myfile.blend, let's create a simple python script pack-and-save.py in the same folder:

import bpy

bpy.ops.file.pack_all()
myPath = bpy.data.filepath
myPath = str(myPath)
bpy.ops.wm.save_as_mainfile(filepath=myPath[:-6]+'_packed'+myPath[-6:])

It simply packs data inside the current file, then save it with the suffix "_patcked".

  • If you don't want to save as a different file, you can remove [:-6]+'_packed'+myPath[-6:] in the last line.
  • You can compress the newly created file, this will make your file lighter on your disk but at the cost of I/O times and ressource usage. Simply add ,compress=True before the closing ) in the last line.

To use this script, open a command line in the same folder and run the following command:

blender -b "myfile.blend" -P pack-and-save.py

That will effectively run a headless Blender, open myfile.blend, execute pack-and-save.py and close. Which results into the creation of a myfile_packed.blend file with all your data packed inside.

Once this is done, you can use this command line to run the rendering itself:

blender -b "myfile_packed.blend" -a

To make both the packing and rendering in one go, you can combine the two command lines using the "double ampersand" conditional execution && like so:

blender -b "myfile.blend" -P pack-and-save.py && blender -b "myfile_packed.blend" -a

It is better to use a double ampersand instead of a single one, so that the render is run only if the packaging was done successfully.

Note that the command line I used for rendering doesn't specify any rendering setting nor file output, it simply does what you have set in your file.

For further reading, see Command Line Rendering — Blender Manual.

$\endgroup$
2
  • $\begingroup$ Thanks for the reply! I'll try it out before marking this as the answer $\endgroup$ Nov 22, 2021 at 19:20
  • $\begingroup$ You welcome! I edited my answer with further detail and how to make the packing & rendering in one command. Check it out! $\endgroup$
    – L0Lock
    Nov 24, 2021 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .