[Python MaxPlus] Retrieve the filename of texture map?


I’m trying to retrieve the filename of a texture map from a material.

I tried this code

It returns the RGB value but not the texture map even though a map is connected.

And so I tried the texmap_diffuse and base_color_map retrieved from the script listener but it gives me the following error

 # For the Vray Material. AttributeError: 'Mtl' object has no attribute 'texmap_diffuse'

# For the Physical Material. AttributeError: 'Mtl' object has no attribute 'base_color_map'

Is there a way around this?

Thank you for looking at my problem.

Disclaimer: Posted this on reddit but I got no replies. So, posting it here. Will update both threads accordingly.

At this time, I got lucky with the documentation. See working code below:

import MaxPlus

# Store object selection
objList = MaxPlus.SelectionManager.Nodes

for obj in objList:
    # Store the map node. texmap_diffuse for Vray. base_color_map for Physical Material
    map = obj.Material.ParameterBlock.texmap_diffuse.Value

    # Retrieve the filename
    filename = map.ParameterBlock.fileName.Value