Access IOR in cycles node material.

I am somehow lost.
Assuming I have a Cube “Cube” with a node-material “Material” with a simple Glass shader, I can’t seem to find my way to access and change the IOR via python.

what are you talking it’s there in latest built

expend the node and you’ll see the IOR button !

show a pic


Hehe, you get that he wants to access the value with a script, right? Python is a very blind snake in that regard… ;D

So, Arexma - when rollover shows ‘Python: blablabla.default_value’, is that a glitch from the developer?

I lol’d - you roam the forum constantly helping people with problems they don’t have - kinda sweet :smiley:
I thought it was perfectly clear that I want to access the IOR value via python.

nodes[“Glass BSDF”].inputs[2].default_value

That’s not really helping me accessing it as I am a C(++) person and just starting with python and I have no idea how to find my way through the API depths.
I tried to get there via“Material”) but from there I didn’t find furhter.
I tried to get there via“Glass BSDF”) but yeah… meh.

in c++ i’d just go
int ior =>getMaterial(“Material”)->GetIOR();
Or SetIOR(123) for that matter. And I seem to be unable to find the equivalent in Python and with Blender :smiley:

IOR =“Glass BSDF”).inputs[2].default_value is certainly not working :slight_smile:

Hmm, very long time ago, when I did more animations, I sometimes needed obscure values for use in expressions (this was in Softimage, like back in version 3.9, pre XSI, hehe)… So I was never that into scripting or expressions, but I kinda faked my way through it when I needed to, you know. There I used a debug mode where I actually got feedback when manually changing values, then I knew what value to call for in the expression… Now, I don’t need stuff like that in what I do nowadays, but I’m pretty shure you still can do this in Maya. There is no such debug function in Blender? (though if they were you’d probably use that, right, hehe?)

Edit: Sry, I’m not helping, I know. I should have kept my nose out of this… My bad. :wink:

I think it’s just a lack of knowledge of, and experience with Blenders datastructure on my side. The solution most likely is trivial, but I rather ask, someone who knows takes 1 min to post the line of code and I can learn from it. Time better spent than digging in the python console the next hour :wink:

sorry i miss read your statement

did you check the script in python forum on nodes for cycles

you might find this IOR somewhere in that script


Well, I dunno what’s acceptable here at BA but perhaps a pm to MikeFarny or DingTo asking politely would do the trick, hehe… Who knows better than dev’s, right? ;D

how about this one here

        if shader.type=='BSDF_GLASS':

from nodes script for cycles


mat =[‘Material’]
mat.node_tree.nodes[‘Glass BSDF’].inputs[2].default_value = 1.0 # set the value here

Thank you.

Good that:[‘Material’].node_tree.nodes[‘Glass BSDF’].inputs[2].default_value = 1.0
works as well.

This simple line helps a lot, opened a knot in my way of looking at the datastructure :wink: