Format a material to a MS script?

Format a material to a MS script?

Anonymous
Not applicable
620 Views
2 Replies
Message 1 of 3

Format a material to a MS script?

Anonymous
Not applicable

Hi,

I have got a script to write(format) a file from the material in the active slot.

This way I have material definitions which I can execute from other scripts

All good but my issue is I cant work out where to start to do it as a loop so I pick up all parametres. I can do it one by one...but for obvious reasons this is very clumsy

 

theMat_Diffuse = theMat.Diffuse
theMat_Diffuse = theMat_Diffuse as string
map_str1 = "meditMaterials" + "[" + current_slot + "]" +  ".Diffuse "+ "= " + theMat_Diffuse
format map_str1 to:mat_file
FORMAT INI_BREAK to:mat_file

 

etc

then I repeat it ...you can see the dumb ugly code attached- it aint pretty!

 

Is there a way to loop &  pick up the properties and the value of the material and any maps without coding things so badly? I have spent hours trying to get a loop that will work and I am getting no where

 

thanks

Mike

 

 

 

 

0 Likes
621 Views
2 Replies
Replies (2)
Message 2 of 3

miauuuu
Collaborator
Collaborator

Why you not save the material as *.mat file? I mean to export the material as material library?

I don't know an easy way to get all props of the givven material. For example in diffuse slot you can have Cellular map, the Cell color can be Fallof map, the fallof map cen be.... and deeper and deeper.

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

akira.kudo
Alumni
Alumni

Hi,

 

This topic was escalated to Salesforce.

Do you still need further assistance? Because one friend suggeted to save the material as *.mat file. Is this working for you?
As far I read you script, it is not bad.

If you need to evaluate all materials in your scene, I think the scenematerials would be helpful like below.

 

 for i=1 to scenematerials.count do
 (
  if (classof scenematerials[i] == Multimaterial ) then
  (
   for j=1 to scenematerials[i].numsubs do
    function scenematerials[i][j]
  )
  else if (classof scenematerials[i] == compositeMaterial ) then
  (
   for j=1 to matList.count do
   (
    if (matList[j] != undefined) then
     function matList[j]
   )
  )
 )

 

I have an old collada maxscript exporter. I can sent it for you, if you are interested in it.
Please let me know.





Akira Kudo

Developer Technical Services

Autodesk Developer Network


0 Likes