How can I do a script to assign materials to selected Faces?

Hi, We want to assign materials to selected faces and apply the option to use nodes.
We could do a script to assign materials from object mode, but it is the whole object, not the selected face.
How do I assign materials to faces selected in a script?
I really don’t know how to add material to the selected face.

Are any of these helpful?

https://blender.stackexchange.com/questions/27631/assigning-material-to-every-second-face-via-python

1 Like

brilliant! This alone did not make it a targeted script.
But that was a great hint, and we were able to achieve the desired script behavior.
In addition, I was able to make the script run much more intelligently.
Thank you!

Excellent, glad it helped.

1 Like