Notifications
Clear all
[Closed] Copying a sub material via maxscript
Nov 08, 2017 12:05 pm
Can anyone help me in how to do this in maxscript?I have a multisub material.I want to get a copy of a specific sub material of it and rename that copy with a suffix “_separated”thanks for your time!
4 Replies
1 Reply
I think your question is not so clear,do you want to copy a sub material to a new material or copy a sub material to a new sub material of this material?
Nov 08, 2017 12:05 pm
I think this code should work,if you want copy first material to second,something like this :
meditMaterials[1]
ID name
1 a test(stanard)
2 b fff(stanard)
3 c None
You can:
tmp = copy meditMaterials[1][1][2]
--copy fff:Standard
meditMaterials[2]=tmp
meditMaterials[2].name=meditMaterials[1][1][2].name+"_separated"
Nov 08, 2017 12:05 pm
pseudo code:
submat = getSubMtl <mat> <index>
newmat = copy submat
newmat.name = submat.name + <suffix>
setSubMtl <mat> <index> newmat
implementation:
fn copySubMaterial from_mat from_index to_mat to_index suffix:"_copy" =
(
submat = getSubMtl from_mat from_index
newmat = copy submat
newmat.name = submat.name + suffix
setSubMtl to_mat to_index newmat
)