Cannot get a specific material from .skp file

It makes the referencing simpler … but you must not assign any “image owned” or “layer owned” material to a SketchUp geometric entity. (The function you linked has a waring to this effect.)

And please post code correctly in the forum …
[How to] Post correctly formatted and colorized code on the forum?