How to read PBR material data in GH in Python based on a GUID

Hi Ore!
Tricky stuff with Rhino.Render.Variant !
… from this thread Create material, apply to layer and export to rmtl file - #13 by andy (thanks to @andy for the conversion step)
I’ve put up a small working example:


c# RBM rendermaterial parameters.gh (7.1 KB)

  private void RunScript(Guid id, string paramName, object XD, ref object val)
  {
    RhinoDoc doc = this.RhinoDocument;
    Rhino.Render.RenderMaterial mat = doc.Objects.FindId(id).GetRenderMaterial(true);

    var v = mat.GetParameter(paramName) as IConvertible;
    val = Convert.ToDouble(v);
  }

To “explore” what are the correct names of the parameters do as @nathanletwory say here Create material, apply to layer and export to rmtl file - #20 by nathanletwory … export your material as .rmtl and open it with a text editor.

1 Like