Get material applied to an object

Hi ! I’m trying to get the material applied to an object in Rhino from grasshopper thought a Guid in python, I summited pseudocode in case anyone knows how to properly implement it, thank you.

I solved it, it was pretty easy, I upload the solution in case anyone could need it


Could you share your Code ? I get a weird error message

Managed to make the code work after playing around:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

sc.doc = Rhino.RhinoDoc.ActiveDoc

index = rs.ObjectMaterialIndex(x)
name = rs.MaterialName(index)
out = name