I am sending my .blends to another remote machine for rendering, and then I render them using command-line. Sometimes, the size of the .blends become as high as 100s of MBs. If I need to adjust only the no. of samples to be used for rendering, I need to upload the whole file again, which I don't want to do.
- 626
- 5
- 15
-
1You can find the list of all arguments here: Command Line Arguments and there is nothing for setting the samples. So I don't think it's possible, I'm afraid. – Gordon Brinkmann Mar 07 '22 at 07:56
-
1of course you could do it by starting a script, which sets the sample it gets from the command line and then render that out – Chris Mar 07 '22 at 10:08
-
@Chris But with which command line argument do you give the samples to the script? – Gordon Brinkmann Mar 07 '22 at 10:12
-
you can give arguments, and interpret these arguments in the script – Chris Mar 07 '22 at 10:13
-
1like this: https://blender.stackexchange.com/questions/6817/how-to-pass-command-line-arguments-to-a-blender-python-script – Chris Mar 07 '22 at 10:13
-
1@Chris Maybe you could evaluate that as an answer... from which I read there I don't understand how to create a script changing the samples of a file on a remote machine. – Gordon Brinkmann Mar 07 '22 at 10:19
1 Answers
There are several ways you can accomplish this. Probably the easiest is to have your command line include a python expression for Blender to execute. If you look at the manual entry for Command Line Arguments you will find
--python-expr <expression>Run the given expression as a Python script.
Assuming that your scene's name hasn't changed, the expression you want is
import bpy
bpy.data.scenes["Scene"].cycles.samples = VALUE
replacing VALUE with the number you want. So your command line needs to look something like
PATH_TO_/blender.exe BLENDER_FILE.blend --python-expr "import bpy ; bpy.data.scenes[\"Scene\"].cycles.samples = VALUE"
Notice that the expression has to fit on one line, so I used a semicolon (;) to separate the import statement from the assignment.
Notice also that the expression contains spaces so I had to enclose it in double quotes and then use backslash to escape the double quotes used in the assignment statement. You may have to adjust this depending on the command line shell that you're using on the remote machine.
One thing to be aware of. The meaning of cycles.samples changed between 2.9x and 3.x because of the introduction of Cycles X. Prior to 3.0 it meant the actual number of samples. Since 3.0 it means the maximum number of samples. In Cycles X, Blender will stop sampling when the Noise threshold is reached. You may want to consider leaving samples alone and changing cycles.adaptive_threshold instead if you're using 3+.
- 33,070
- 10
- 35
- 79