# Modify properties in the .blend file (command line)

I'm writing an application which will display a nice looking 3D model of a building. The building will have some areas which will change their color depending on some data points provided by the application.

The application will invoke blender's command line rendering feature to generate a PNG out of the .blend file, which then can be displayed in the UI.

The point where I'm stuck is how to change some material colors in the .blend file.

All hints are appreciated.

• Welcome to the site :) What do you mean by changing colors? – p2or Mar 11 '16 at 11:14
• Thank you :). Imagine rendering a room of the building red or green, so the material's color (or some lamp's color) must therefore be changed. – thomai Mar 11 '16 at 11:28
• That could be too broad for this site. Material or lamp color? Might be a good idea to split up the question. What render engine are you using? Cycles or Internal? – p2or Mar 11 '16 at 11:37
• Changing the color depends on the engine... Anyway, you can run a given python script file via -P option, see the manual – p2or Mar 11 '16 at 11:55
• – p2or Mar 11 '16 at 12:24

## 1 Answer

The following command line will do the job (-P will run the given python script before rendering):

blender -b OG1.blend  -P ChangeColor.py -o Render.png -f 0


ChangeColor.py:

import bpy

bpy.data.materials["NameOfMaterial"].diffuse_color = (0, 1.0, 0)


The value ranges for the color channels are [0 to 1.0].

Thank you for your help, poor! Blender ist just too awesome! <3