Someone should really make this video a sticky for this forum.
Every one should watch this video. It shows you how to help yourself. Basically Blender 2.5 has a feature to show you what python code you just executed for any action in the GUI. So if you want to know how to create a texture just put the console in report mode, create an actual texture in the interface and watch Blender 2.5 spit out the code needed to perform such an action. If you need an armature, just do the same thing.
So you can see how important it is to watch this video. It shows you how to setup the console to report back the code that your latest actions just generated.
Looks like you are correct. I can see the code for creating a new texture or material, but not changes to the texture (like switching from cloud to musgrave).
In those cases, I guess that is where the bubble help python code comes in handy. You can always put the outliner in Datablock mode and examine the entire scene structure. Hover over an element in the tree and the popup help will give you a brief code syntax for accessing that element/property. This popup help also appears in the Properties window as well.
You can also derive what methods and properties are availabe from any given variable with the print(dir()) function combination.
So I see that the console spits out.
bpy.ops.texture.new()
I create script like this.
myTex = bpy.ops.texture.new()
print(dir(myTex))
Now, if I examine the Blender window I can see what further options I can use to operate on “myTex”. This is just how I work. I do pop in and read the docs on occasion, but with popup help, the console and print(dir()) I can ususally figure out what the syntax is for the next step in my script. This is a great improvement over 2.49 (IMHO).
now this is not adding a new mat
but seems to be used for changing the parameters for a specific mat !
but how do you use this ?
where do you put it - is it just after adding a new mat or how do you select a mat ?
is is after adding a new mat in the scene
like in bpy.ops.material.new() ?
there is no example on how to write it
if i have to i’ll write a new page for wiki to show this ounce i know how to use it !
note: understanding the formal desription is not easy for non programmer like me and the best way i guess is to give a minimum qty of examples then it becomes a lot easier to understand and use it !
for the outliner can you show what you mean
causei don’t see bpy command
i can extend and see mat and texture ect…
but no equivalent bpy command shown as a tool tiop for instance
You have to change the pathname in the last line to where the picture is located, of course. Btw, I have created a C:\home homas folder on my windows box to be able to move files between windows and ubuntu.
The texture shows up as an ORCO texture in the color channel on the default cube. I assume that the selected object is a mesh, and that it has exactly one material already.
and i change that the path name for the file
now i ran the script and got no errors on console
if i used your filepath name
but if i put my own path on my disk
i get an error like
cannot decode unicode from 2 to 4
i did use Tab at the beginning so i guess
it did not like this tab but all my script are done with tab
so not certain why i get this error on this line
now on the render i did not see the image texture on the cube
any idea why this is not seen
but i did see 2 mat and on the first mat there was 3 textures
so i guess this part is working nicely
note: to see pic ic an open a new WIP where i can add pic anytime!
this is the first time i see good example for mat and text
don’t know where you’v seen this but it’s very good doc
Materialname1=‘Mat1’
mat = bpy.data.materials.new(Materialname1)
mat.alpha = 0.8
mat.diffuse_color = (1.0, 0.0, 1.0) # This diffuse color will take a Magenta color
Map Wood texture to specularity
mat.add_texture(texture = text1, texture_coordinates = ‘UV’, map_to = ‘SPECULARITY’)
MAT1_mtex = mat.textures[0] # This the second material in list 0 ,1
Create new material
Pick active object, remove its old material (assume exactly one old material).
ob = bpy.context.object
print (’ Object name The Cube remove mat =’,ob.name)
bpy.ops.object.material_slot_remove()
Add the two materials to mesh
me = ob.data
me.add_material(mat)
MakeMaterials()
##################
i can make the wood text t appears if i manually set the color in text panel
any idea why this wood text does not appear in render?