Data conversion failed from Goo to Shader

Hi everyone,
I’m writing a component in C# for rendermaterial output, but I can’t seem to find the correct parameters for the output, can you help me?

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("renderMaterial", "Material", "output renderMaterial", GH_ParamAccess.item); //---BUGGGGGGG-----

        }
            double Reflection = 0.3;
            double Smoothness = 0.1;

            Reflection = Math.Min(Math.Max(Reflection, 0), 1);
            Smoothness = Math.Min(Math.Max(Smoothness, 0), 1);
            Rhino.DocObjects.Material material = new Rhino.DocObjects.Material();
            //material.SetBitmapTexture(fileName);
            material.ReflectionColor = cor;
            material.DiffuseColor = cor;
            material.AmbientColor = System.Drawing.Color.Black;
            material.EmissionColor = System.Drawing.Color.Black;
            material.Reflectivity = Reflection;
            material.ReflectionGlossiness = Smoothness;

            Rhino.Render.RenderMaterial renderMaterial = Rhino.Render.RenderMaterial.CreateBasicMaterial(material);

            
            DA.SetData(0, renderMaterial);

error message : Data conversion failed from Goo to Shader

material.gh (5.5 KB)
Here’s the original script David wrote, and it works fine, but when I code it in VisualStudio, the output gives an error.

Hi.

That script is using GH_Material Class … you are not using any constructor of that class in your script.

1 Like

Thank you for your tips, do I need to create a GH_Goo class to encapsulate the data and then output GH_Goo<>? It seems like a huge job, but I will try. . .