By Forester - Wed Sep 15, 2021 3:07 pm
- Wed Sep 15, 2021 3:07 pm
#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)
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.