0
$\begingroup$

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)

Run-script

//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.
load_a_list_of_applicable_object_names

go_through_all_objects_in_scene

//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.
remove_object_faces
modifiers > decimation > planar decimation > apply

// retexture object from a multi-texture file to a single texture image
retexture_object
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"
TEXTURES > MAPPING:
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!

$\endgroup$

closed as unclear what you're asking by Vader, gandalf3, Keavon, CharlesL, Gunslinger Feb 24 '14 at 15:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ You should use # for the comments. Also what exactly do you need help wit? $\endgroup$ – Vader Feb 23 '14 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 '14 at 18:58
2
$\begingroup$

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.ops.texture.new()
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?

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.