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.default_value
When i past it in the console, i get an error. How can i know what the begining is ? bpy.data.“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.
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 bpy.data.materials
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 : http://comments.gmane.org/gmane.comp.video.blender.devel/30914 )
RMB to get the API doc page gives that : http://www.blender.org/documentation/blender_python_api_2_63_17/bpy.types.NodeSocketRGBA.html#bpy.types.NodeSocketRGBA.default_value and nowhere “bpy.data.materials[‘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 bpy.data.materials. 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 ?
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.