Hello there I'm trying to learn how to python to help me automate parts of my workflow which take a long time and are repetetive (so i can go do the ironing while it does all that). But I thought I better ask if scripting can possibly do it first, as its the only real need I'll have for scripts, I believe. I have written down a list of what I want the script to do in quasi-programming terms. I know some of it is possible, but would like to know if it all is!

(I've also put in ITALICS how i would MANUALLY accomplish these operations, just in case descriptions dont work out well)


//tex_directory is the hard disk location where blender will look for the texture to replace the one already on the object
tex_directory = "c:\mytextures\"

// Below command loads a list of "applicable" object names. The aim is that it will later scan through all objects in the scene, and if their name matches, it will perform the texture/optimization commands on them.


//compare names of scene objects with loaded list to see if we find an object we want to modify.
if object_name = any_applicable_object_name

// apply planar_decimation modifier to object to remove extra faces not needed.
modifiers > decimation > planar decimation > apply

// retexture object from a multi-texture file to a single texture image
MATERIALS > duplicate material (plus button) > rename new material to object name
TEXTURES > duplicate texture (plus button) > rename new material to object name+"_tex"
TEXTURES > texture's TYPE to "image or movie"
TEXTURES > image > open > TEX_Directory+object name+".jpg"
coordinates - "global"
projection "cubic"
SIZE X,Y and Z = "10"
TEXTURES > Influence > Diffuse > Alpha = 1
end if //return to comparing rest of scene objects to "applicable" objects list.
if end of scene objects - end script

Has anyone even the foggiest idea how to do this? I've managed to create a decimate modifier (with default values which I dont want) and thats about it!

  • $\begingroup$ You should use # for the comments. Also what exactly do you need help wit? $\endgroup$
    – Vader
    Feb 23, 2014 at 13:42
  • 1
    $\begingroup$ This question appears to be off-topic because it is asking others to write their code. $\endgroup$
    – Keavon
    Feb 23, 2014 at 18:58

1 Answer 1


To help you to get started:

You already know how to do it manually, that is good because you find most of the actions in the an area visible after moving the info header (main menu bar) down.

enter image description here

There you could select the lines of interest and copy and past them into the text editor.

bpy.context.space_data.context = 'MATERIAL'
bpy.context.space_data.context = 'TEXTURE'
bpy.data.textures["Texture"].type = 'IMAGE'

Most of the python snippets you need are already in one of the posts here. E.g. loop over all objects (Run an edit-mode operator on every object in the scene).

import bpy

scene = bpy.context.scene
for ob in scene.objects:
    print( ob.name )

Reading a file: Mapping an algorithm to an animation

Also useful when exploring methods and data structures: Is it possible to dump an Objects Properties and Methods?


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