Notifications
Clear all

[Closed] Copying a sub material via maxscript

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
(@momo2012)
Joined: 11 months ago

Posts: 0

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?

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"

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
)

@denisT, momo2012
Thanks guys for the help! I went for a workaround but now implemented the methods you guys mentioned.