Get path to texture file


#1

Where in RhinoCommon might I access the path to a particular bitmap file that is used as a texture (and not necessarily already stored in the bitmap table)? I looked around in DocObjects.Material as well as the various render related classes, but it wasn’t obvious…

Thanks, --Mitch


#2

Hi Mitch.

You can check the texture path like so:

import scriptcontext as sc

material = sc.doc.Materials[index]
texture = material.GetBitmapTexture()
try:
   print material.GetBitmapTexture().FileName
except:
    print "texture has not been assigned"

where index is the material index from rendering material table:

import rhinoscriptsyntax as rs
import scriptcontext as sc

obj_id = rs.GetObject()
obj = sc.doc.Objects.Find(obj_id)
print obj.Attributes.MaterialIndex

#3

Ah, cool, I saw Material.GetBitmapTexture() but didn’t realize that the texture returned might have attributes like filename… I probably would have found it eventually, but this helps a lot!

Thanks djordje ! --Mitch