1

This linked post does not answer the question. That post is for a single script, and to do this, you still need the GUI. I have no GUI access and 1000 unique script files. I do not think this will work. The only work around I have found is to not use render farms and instead use a computing cluster like aws where you can use the command line below to render.


I have 1000 script files that set various parameters of my Blend scene. Previously, I have been rendering with the command line like this:

Blender -b myFile.blend -P myScript0001.txt -f 1
Blender -b myFile.blend -P myScript0002.txt -f 2
Blender -b myFile.blend -P myScript0003.txt -f 3

In order to render this on a render farm, I cannot use the script files, they must be included in the Blend file. Is there a way to update the blend file to include the script file by the command line? I do not have the option to use the GUI to do this.

Or maybe I reference a json file in my script that I host publicly on my website? Is something like this possible, for example:

#myScript0001.txt
import bpy
bpy.data.objects["Empty"].location[0] = {link-to-json-file}
brockmann
  • 12,613
  • 4
  • 50
  • 93

1 Answers1

3

Read the files write to text, save blend.

Here is an example script.

  • Globs all text files in folder (hardcoded, could pass as argument)

  • Create a textblock with same stem name

  • Read the contents into textblock

  • Save blend to keep changes.

Script, edit directory path to suit.

import bpy
from pathlib import Path

glob all txt files from

dir_path = "/home/batfinger/foo" txt_dir = Path(dir_path)

glob for txt files.

glob = "*.txt"

for f in txt_dir.glob(glob): text = bpy.data.texts.new(f.stem) text.write(f.read_text())

save

#bpy.ops.wm.save_mainfile()

batFINGER
  • 84,216
  • 10
  • 108
  • 233