How can I change the color in IronPython?

I am sorry, but Why doesn’t this code work?

import rhinoscriptsyntax as rs
import System

obj = rs.GetObject()
rs.ObjectMaterialSource(obj, 1)
index = rs.ObjectMaterialIndex(obj)
color = System.Drawing.Color.Blue
rs.MaterialColor(index, color)

print("test")

Or

import rhinoscriptsyntax as rs
import Rhino
import System

obj = rs.GetObject()
nColor = System.Drawing.Color.Blue
mat = Rhino.DocObjects.Material()
mat.DiffuseColor = nColor
rMat = Rhino.Render.RenderMaterial.CreateBasicMaterial(mat)
tab = Rhino.RhinoDoc.ActiveDoc.Objects
Rhino.DocObjects.Tables.ObjectTable.ModifyRenderMaterial(tab, obj, rMat)

print("test 2")

Please!!
1.py (225 Bytes)
2.py (270 Bytes)

This color

Here
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_ObjectTable_ModifyRenderMaterial_2.htm

Some more with ObjectTable:

tab = Rhino.RhinoDoc.ActiveDoc.Objects

Updated

Oh my god, I did it

rMat = Rhino.Render.RenderMaterial.CreateBasicMaterial(mat)
2 Likes