Creating TexBitmaps via IronPython for V-Ray materials

I’ve written (with help from Claude.ai) a python script (Rhino 7 IronPython 2.7) that tweaks some V-Ray materials (that have already been convert from Rhino materials, with the name leaf or flower in it).

The diffuse tex is set up in a TexBitmap with the the filename XYZ_albedo.jpg

I want to create 2 new TexBitmaps, following the naming scheme: XYZ_translucency.jpg and XYZ_glossiness.jpg (with the same file location as the diffuse map), and map them to brdf.translucency_color_tex and brdf.reflect_glossiness_tex

Can someone explain how to do this?

import rhinoscriptsyntax as rs
import Rhino
import System
import rhVRay as vray

with vray.Scene.Transaction() as f:
    # Get all V-Ray materials of type MtlSingleBRDF from the scene
    vray_materials = vray.Scene.PluginsByType("MtlSingleBRDF", True)
    
    # Loop through each V-Ray material
    for material in vray_materials:
        material_name = material.Name
            
    with vray.Scene.Transaction() as t:
        for material in vray.Scene.Materials:
            brdf = vray.Scene[material.brdf]
            if brdf.Type != "BRDFVRayMtl":
                continue
            # Check if name contains "leaf" OR "flower"
            name_lower = brdf.Name.lower()
            if "leaf" not in name_lower and "flower" not in name_lower:
                continue
            print("Processing: \"{0}\" ...".format(brdf.Name))
            brdf.translucency = 6
            brdf.translucency_amount = 0.3
            brdf.refract_ior = 1.6
            brdf.fresnel_ior = 1.3
            brdf.refract_glossiness = 1
            brdf.refract_thin_walled = 1
            brdf.reflect_color = [1, 1, 1, 1.0]
            brdf.bump_amount_float = 1
            brdf.translucency_color_tex = # ..._translucency.jpg
            brdf.reflect_glossiness_tex =   #..._glossiness.jpg

print("Done!")​

reposted here:

Yes… hoping for a little guidance from you to be honest @Nikolay :folded_hands:

solution: Creating TexBitmaps via IronPython - Chaos Forums