Texture slots list via maxscript

Texture slots list via maxscript

Anonymous
Not applicable
3,545 Views
4 Replies
Message 1 of 5

Texture slots list via maxscript

Anonymous
Not applicable

How do I get a list of the texture slot names? I know about getPropNames and getProperty, but getPropNames returns all properties but I want the names of the just the texture slots.

 

I can use getNumSubMtls to get the number of slots in a multi sub material, but if I am using a standard or Vray material, then it returns 0, which is what I expect, but I cannot see how to return just the names of the slots, not the textures in them, the actual slot names i.e:

 

.texmap_diffuse

.texmap_roughness

.texmap_self_illumination

etc.

I am sure I have done this before but I cant find the snippet in my list. I could go through them and add a map to see how the macro recorder shows it, but thats not very programatic.

 

Pointers welcome. Its going to be so glaringly obvious that I will be embaressed when I find out.

 

cheers

0 Likes
Accepted solutions (1)
3,546 Views
4 Replies
Replies (4)
Message 2 of 5

Swordslayer
Advisor
Advisor

There's the getNumSubTexmaps (<material> | <texture>) method and getSubTexmapSlotName (<material> | <texture>) <index> to get its name (not the property name, this one is the displayed name - to get the texture itself use getSubTexmap (<material> | <texture>) <index>). Same with submaterials and their slot names using getSubMtlSlotName <material> <index>.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for the reply, but that is not what I want. I can get all the information from the material, but I want specific list of certain items/properties, not a list of everything. I am looking to get a list of the properties that are the slot definitions, not the map/slot names or textures within them. I want to be able to extract a list of the properties that are the definition of the slots. On a standard VrayMtl, they are this:

 

.texmap_diffuse
.texmap_reflection
.texmap_refraction
.texmap_bump
.texmap_reflectionGlossiness
.texmap_refractionGlossiness
.texmap_displacement
.texmap_environment
.texmap_translucent
.texmap_refractionIOR
.texmap_hilightGlossiness
.texmap_reflectionIOR
.texmap_opacity
.texmap_roughness
.texmap_anisotropy
.texmap_anisotropy_rotation
.texmap_refraction_fog
.texmap_environment

 

I want to be able to get just these names/properties for any material I choose, whether it be directly from the Medimaterials[index] or from the existing scenematerials[index].

 

I have used getPropNames and isProperty before, using code like this:

 

isProperty scenematerials[2] #Diffuse

isProperty scenematerials[1].materialList[1].diffuseMap #divColor1

getPropNames scenematerials[1].materialList[1].diffuseMap

 

but, as mentioned, this is not the info I want, its the elements listed above.

 

0 Likes
Message 4 of 5

Swordslayer
Advisor
Advisor
Accepted solution

Okay, it would be better if you told me what are you using these property names for if not for getting the maps. Yes, you can do that, but it comes with quite a few catches and it depends on the way the material is implemented. For example, it won't work on standardMaterial where the map properties are not individual properties, the maps are stored as an array of maps and the properties like 'bumpMap' are only aliases for the indices of that array. Anyway, here you go:

 

props = stringStream ""
showProperties meditMaterials[1] to:props
propList = filterString (props as string) "\n"

for prop in propList where
(
	local tokens = filterString prop " .:()"
	tokens[tokens.count] == "texturemap"
)
collect tokens[1] as name
Message 5 of 5

Anonymous
Not applicable

Hi Swordslayer, I recently found this post which I had never replied to to say thanks, so please accept my late thanks for this script, it helped me out.

 

Kudos

0 Likes