Python question

In the workflow I’m developing, I have a scene set up with a character made of four parts. These are imported as alambic files. I would like to write a script that would assign the shaders (already in the scene) to the objects so I don’t have to do it manually every time I update my scene (changing the path of the cache crashes Blender, I filed a report already. This is for a workaround).

In the python tooltips, I can see the commands being executed, like

bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(4.70432, 26.7865, 4.33576))

when I create a cube. The problem is, I don’t get any commands when I assign a shader to an object. Or when I select an object, or many other commands. So how can I find how to do this? If I search for shader in the docs, I get about 1000 results. In Maya, you have to turn ON a thing called “echo all commands” to see them all. Maybe there’s something similar in Blender, something that will display every thing being done.

In 2.79b, there is a script under Help menu that creates a text containing all operators.
In right click menu, there is an item to open a link to online documentation of python API.

But because of beta status of 2.8, those links are not available from Blender UI, yet.
But you can find documentation about python API, here.
https://docs.blender.org/api/blender2.8/index.html

Do you mean “operator cheat sheet”? That’s only showing the python tool tips. As I mentioned, searching for “shader” in the docs gives me a very very long list of results. Searching for “shader assign” gives no results at all. So back to square one.

Yes. That 's what I mean. It is not there in 2.8.

Sorry, I did not read carefully.

A search with “material assign” should guide to this.
https://docs.blender.org/api/blender2.8/bpy.ops.object.html#bpy.ops.object.material_slot_assign

That is slot ID that is assigned to faces when using the button.

But you should read Quickstart, API Overview, API reference usage, … all these pages of API docs before trying to make a script.

You will learn that for this particular case, it is better to pass by bpy.data access or bpy.context access than bpy.ops one.

For example, in those pages, you can find that.
https://docs.blender.org/api/blender2.8/info_tips_and_tricks.html#show-all-operators

Yes. That 's what I mean. It is not there in 2.8.

If you go in the scripting tab, you will find it in the bottom left. :slight_smile:

I will check out the info you just sent me. But it would be very useful that the python tooltips (or operator call sheet) would give more feedback on what is happening.

thanks :slight_smile: