Like the title says, I want to create a Python (or Node.js program, although I think Python would be a lot better for this) that creates a new Blender file and is able to change the colour of the default cube. I want to do something more advanced than that, but I think once I learn how to change the colour of the cube using a Python program I will be able to get the hang of it.
Can run blender in background mode.
Run the command using language of choice. For example in python using
subprocess.Popen(...) or a 3rd party module like
plumbum or something akin to https://stackoverflow.com/questions/17733849/launch-an-external-application-from-node-js via
Very basic example script. My startup file has default cube with material "Material". The material's diffuse color in 2.79 is rgb, in 2.8 rgba. Simply sets material to red, and saves the file as "output.blend"
import bpy mat = bpy.data.materials.get("Material") red = (1, 0, 0) if len(mat.diffuse_color) == 4: # has alpha red += (1) # alpha mat.diffuse_color = red bpy.ops.wm.save_as_mainfile(filepath="output.blend")
Run from command line with
blender -b -P test.py
creates a blend file named
output.blend with a red cube in the folder in which it was run from terminal.
Extend by passing arguments see