#401050
Here is a little, simple script I am trying to write, but I must be making numerous errors.
I just need the proper syntax for changing the IOR Value of the first BSDF in the first layer.

I've managed to read the first layer, and the first BSDF in the first layer. But I'm having problems writing a correct statement to change the IOR Value. Can anyone help me with this?)


Also, I sure could use some help in understanding how to write the "Set" commands so that the script signals back if the Set command fails.

################################################################
# Edit just the IOR Value of the first Opacity and Ghost BSDF layer
################################################################

from pymaxwell5 import *

def edit_multilayer_material(inPath,outFolder,outMxs):
# Read scene from disk
scene = Cmaxwell(mwcallback_cb)
ok = scene.readMXS(inPath)

if ok == 0:
print("Error reading scene from file")
return 0

# Read material
material = scene.getMaterial( 'Glass' )
if material.isNull():
print("Wrong material name?")
return 0

# Get first layer
layer = material.getLayer(0)

# Get first BSDF
bsdf = layer.getBSDF(0)

# Get/set BSDF IOR value
Creflectance_getIOR(0)
Creflectance_setIOR(1.51,0.0)


if not os.path.exists(outFolder):
os.mkdir(outFolder)

# Save changes
outPath = outFolder+'/'+outMxs
ok = scene.writeMXS(outPath)
if ok == 0:
print("error saving",outPath)
return 0
else:
print(outPath)

return 1

if __name__ == "__main__":
inPath = 'd:/mr_scenes/GlassTesting_sdrevision1.mxs'
outFolder = 'd:/mr_scenes/GlassTesting_sdrevision2.mxs'
outMxs = 'sample_scene_mat_edited.mxs'
edit_multilayer_material(inPath,outFolder,outMxs)
You do not have the required permissions to view the files attached to this post.
#401051
Hi

It looks like you are using Maxwell Render 5/scripts/python/edit_multilayer_material.py as your starting point which is good

this line in that script gives you a handle to the instance of the Creflectance class in your bsdf that you can manipulate
Code: Select all
reflectance = bsdf.getReflectance()
This is how you retrieve the current value
Code: Select all
nd,abbe,ok = reflectance.getIOR()
print('Nd',nd,'abbe',abbe)
This is how you set the value
Code: Select all
ok = reflectance.setIOR(1.9,100)
the ok variable stores success or failure

...and 3 Days later, 82.528 Views !!! ...NL, every[…]

Hello dear customers, We have just released a new[…]

grass generator extension

Just downloaded MWR5 for Rhino 6 and want to use g[…]

Hello everyone, I have a new bug with the latest M[…]