I’m trying to duplicate a material but I can’t see any methods to do this in the docs. I’d like it to be a total duplicate including the attribute library, texture, colour etc… - this is obviously simple to do when navigating the material library (right click > duplicate…)
Am I missing something in the docs, or do you have to do this by creating a new material and manually setting all the options in the material to match?
In the Materials palette - select the materials that are “In Model.”
Materials need to be in the current model in order to copy them.
Select the material you want to copy - and hit the plus sign to duplicate.
Rename it accordingly.
If you have version 2017 or higher, you might try going through a temporary file.
(1) Change the name of the source material to that which you want the copy to be.
See Material#name=
(2) Save out a SKM file using the copy name for the SKM
See Material#save_as
(3) Change the name of the source material back to what it was before.
(4) Load the copied material into the model’s materials collection:
See: Materials#load
It seems that I remember that at one time attached attribute dictionaries did not save with the SKM. I think this was fixed but do not remember quite when (ie, what version.)
I do see that there was an attribute dictionary fix (re array data) in v2019.2.