# Data conversion failed from Goo to Shader

**URL:** <https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639>\
**Category:** Grasshopper\
**Tags:** windows, csharp, grasshopper-sdk\
**Created:** [August 26, 2023, 7:00pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639 "2023-08-26T19:00:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiYing](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/liying/32/492855_2.png) [@LiYing](https://discourse.mcneel.com/u/LiYing)\
**Post date:** [August 26, 2023, 7:00pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639/1 "2023-08-26T19:00:25Z")

</div>

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?

 ![微信截图_20230827025331](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/d/9/dd9dd7c3a63bf14158bee3dce0e594f6a2075be3.png)

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

        }

```

```auto
            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);

```

---

<div class="post-metadata">

**Author:** ![LiYing](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/liying/32/492855_2.png) [@LiYing](https://discourse.mcneel.com/u/LiYing)\
**Post date:** [August 26, 2023, 7:11pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639/2 "2023-08-26T19:11:56Z")

</div>

![20230827030817](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/f/0/cf000ffdb062bcf0204d03971d2a199d9bac3ea7.png)

error message ： Data conversion failed from Goo to Shader

---

<div class="post-metadata">

**Author:** ![LiYing](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/liying/32/492855_2.png) [@LiYing](https://discourse.mcneel.com/u/LiYing)\
**Post date:** [August 26, 2023, 7:22pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639/3 "2023-08-26T19:22:20Z")

</div>

[material.gh](https://discourse.mcneel.com/uploads/short-url/c53JEIaD398o8Bz6oCt8lvmVRW1.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.

---

<div class="post-metadata">

**Author:** ![maje90](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/maje90/32/762888_2.png) [@maje90](https://discourse.mcneel.com/u/maje90)\
**Post date:** [August 27, 2023, 12:13pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639/4 "2023-08-27T12:13:14Z")

</div>

Hi.

> [@LiYing](#):
>
> Here’s the original script David wrote

That script is using [GH\_Material Class](https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_Kernel_Types_GH_Material.htm) … you are not using any constructor of that class in your script.

---

<div class="post-metadata">

**Author:** ![LiYing](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/liying/32/492855_2.png) [@LiYing](https://discourse.mcneel.com/u/LiYing)\
**Post date:** [August 27, 2023, 5:39pm UTC](https://discourse.mcneel.com/t/data-conversion-failed-from-goo-to-shader/164639/5 "2023-08-27T17:39:42Z")

</div>

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. . .

> [@maje90](#):
>
> Hi.
> 
> > [@LiYing](#):
> >
> > Here’s the original script David wrote
> 
> That script is using [GH\_Material Class](https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_Kernel_Types_GH_Material.htm) … you are not using any constructor of that class in your script.
