I’m trying to create a bunch of blender textures to use as brushes in a script…
Ideally I’ll make this an operator that can be pointed at any directory and load all the images and add then to textures…
in 2.49 I could:
import os
import bpy
directory = "/media/mikedata/Projects/Alphabrushes"
file = os.listdir(directory)
for f in file:
img = bpy.data.images.new()
img.name = f
img.filename = directory + f
img.reload
tex = bpy.data.textures.new()
tex.name = f
tex.type = 8
tex.image = img
but in 2.5 there doesn’t seem to be an equivalent to " bpy.data.images.new"
Also, in 2.49 you could call a file selector as follows:
import Blender
from Blender import Window
#
def my_callback(filename): # callback for the FileSelector
print "You chose the file:", filename # do something with the chosen file
#
Window.FileSelector (my_callback, "Choose one!")
what is the equivalent in 2.5?
It seems to me that there are operators for blend files via selector and images via selector…
but I can’t figure out the general case…
Thanks! I seem to have done the same thing in parallel since I read your first post!
I think i need to force an "update"somehow,because a “cloud” texture (the default) doesn’t have an image attribute… eventhough we’ve just changed it to an image type python hasn’t caught up!
you mean i would have to change all backslash for foward slash !
may this is shown on the API page
but still it should not gie any unicode error i think
cause i entered it in the filed manually
if i had copied it from explorer it might include some unicode charact!
i’ll try to find the API page for this add imag
could not find any of these bpy.data!
but did find the new one
bpy.ops.image.open path="", filename="",
how should i read this is there a coma between the path and the filename?
That sounds resonable. Right now we simply changed an attribute (“type”) inside the texture object.
Now we need to tell Blender to “change” the object according to this attribute (i think) … which then also has an “image” attribute.
Will try this when I get some time.