Right now you can set a waveguide or 3D a object’s material properties to a specific material using VB script, but the materials and profiles have to be created by hand in the profiles and materials editor.
For the next OptiFDTD release (12.1, latter this summer), we implemented a workaround:
materials and profiles will be described as XML files and you will be able to import them in the profiles and materials designer. It means that if you need a very large number of materials, you can create a script that will generate these materials.
You can them import them in the project and use them in VB script.
It’s not yet perfect, but that should help you hopefully 🙂