Assigning materials to bodies and saving them as separate STL files

Hello,

I would like to create an add-in where the user can assign different materials to different bodies. Once completed, the user will click a button, which will export each separate body as a separate STL file (with a filename that has the assigned material's name). I have a specific list of various materials that I would like to show in a drop-down menu.

For this purpose, should I create a UI for such a material list or should I have the user choose a material using SolidWorks' built-in material feature (see below)?

Lastly, once the material IDs are assigned, how can I export each body with a filename that includes the selected material's name?

Thank you for your help.

Best regards

SolidworksApi macros