There appears to be a software defect in the SketchUp API. Loading the textures into TextureWriter and then attempting to access their filenames using TextureWriter.filename(index) returns only empty strings. However, if you call TextureWriter.write_all beforehand:
# Display texture names
def display_tex_names
$tw = Sketchup.create_texture_writer
load_textures(Sketchup.active_model.entities)
$tw.write_all("D;", false)
tex_index = 1
while (tex_index <= $tw.count)
UI.messagebox($tw.filename(tex_index))
tex_index += 1
end
Sketchup.active_model.commit_operation
end
then the filenames are returned properly.
Confusing matters further, the TextureWriterindices are one-based rather than the expected zero-based array.