copy data path problem

Hi all,
I’m trying to start working with the blender API 2.63.17.
I tried to modifie the RGB value of the Cycles Diffuse shader. I right licked on the color in the UI and copied the data path. I get this : nodes[“Diffuse BSDF”].inputs[0].default_value
When i past it in the console, i get an error. How can i know what the begining is ?“what you copied” doesn’t work. I tried to read the api doc. But their are many many answer for keyword “material” and i don’t know wich one to use. :frowning:

How can i found in general (not only for that rgb value) the full python api call / data path ? Why does that “copy data path” in the UI ( a realy usefull and good idea ) not copy the full path ?


it doesn’t give you the full path, as it generates the data path via the used object type. So you gotta find out where such objects are stored at. I wouldn’t make much sense and confuse newbies if an absolute (full) data path was copied, as it becomes invalid as soon as you rename the object.

A diffuse shader node is part of an Material, thus it has to be somewhere in

Example for setting color to red:[‘Material’].node_tree.nodes[‘Diffuse BSDF’].inputs[0].default_value = (1,0,0,1

Thanks for your reply :slight_smile:

For those reading those post for a solution : Most of the calls are loged in the info window (in the top bar) (just drag down the top menu, then use a button, the API Call will be displayed there)
For some buttons, ctrl+c works as well to get the full path.

But for some functions, like that diffuse color in cycles nodes, ctrl+c copy the value, and nothing is displayed in the info window (don’t know why, i asked the devs, waiting for an answer)
and that data path is annoying for many newbies I thing (googling first for my problem i’ve seen many post about that problem, even on the devs mailing list : )
RMB to get the API doc page gives that : and nowhere “[‘your material’].node_tree.wanted_function” is mentionned.
For me, it would be easier to see wich part must be adapted ( here ‘your material’) as guessing it must be in I’m not good at guessing where people sort things, don’t ask me where the spoons are at a friends home. And so are many people, we just have different way of thinking and sorting things. It’s ok the blender devs arranged the API like they did, but it’s not a universal way of thinking/sorting.
Blender has many functions, so would be great to know how to ask blender “where is that one”.
Is really guessing the only way ?

well, you can find a lot in API docs, bpy.types

but it’s true, that there should be a note in API or tooltip, where objects can be found

I’m just getting started with Python scripting in Blender, and trying to write a script that changes the viewport color (.difuse_color) to the cycles shader color (.NodeSocketRGBA) [I feel like it should automatically do this anyway, but I digress] and having a devil of a time figuring out how to call up the .NodeSocketRGBA value as well.

the answer is already given in this thread, however here’s a slightly more complex example:

import bpy

mat =['Material']

rgba = []
rgba.extend(mat.diffuse_color) # rgb

# alpha
if mat.use_transparency:
    rgba.append(1.0)['Material'].node_tree.nodes['Diffuse BSDF'].inputs[0].default_value = rgba