Retrieve the preview of material(swatch thumbnail) in maxscript

Retrieve the preview of material(swatch thumbnail) in maxscript

Veena_Revankar
Explorer Explorer
2,144 Views
6 Replies
Message 1 of 7

Retrieve the preview of material(swatch thumbnail) in maxscript

Veena_Revankar
Explorer
Explorer
I am looking to retrieve the preview of material (swatch thumbnail) in the form of image (jpg,jpeg,png) from the material editor in maxscript. I am using 3ds max.

Please help.

0 Likes
Accepted solutions (2)
2,145 Views
6 Replies
Replies (6)
Message 2 of 7

miauuuu
Collaborator
Collaborator
Accepted solution

Check this thread.

https://miauu-maxscript.com/
0 Likes
Message 3 of 7

Veena_Revankar
Explorer
Explorer

Thanks @miauuuu . The solution is working but how do we get material index for only the materials used in the object ?

Please do help.

0 Likes
Message 4 of 7

miauuuu
Collaborator
Collaborator
Accepted solution

 

Store the material of material slot 24 to a variable:  matSlot24 = meditMaterials[24]

Get the material of your object and add it to material slot 24: meditMaterials[24] = selection[1].material

The material index is the index of the  slots of the Compact Material Editor, so when you use any of the functions from the cgtalk thread, use 23 as material index(because the material index is 0 based).

After you get the material preview use meditMaterials[24] = matSlot24 to put back the original material, applied to material slot 24.

 

https://miauu-maxscript.com/
0 Likes
Message 5 of 7

Veena_Revankar
Explorer
Explorer

Thanks a lot @miauuuu. It is working.

0 Likes
Message 6 of 7

Veena_Revankar
Explorer
Explorer

Currently the material preview we can get is of very low quality that is 24x24. Is it possible to get it of high resolution ?

0 Likes
Message 7 of 7

Veena_Revankar
Explorer
Explorer

I have changed the size. Now I could get material preview of good quality.

0 Likes