Output GH_Structure gives structure{n;n;n; ....}

Hello.


I have a short and probably simple question.
When I’m assigning my GH_Structure<GH_Point> to an output, it gives me strange data. (structure{n;n;n; …} )

The code is:

  *private void RunScript(ref object oTree)*
  •  {*
    
  •    Point3d[,] pts = new Point3d[10, 10];*
    
  •    for(int i = 0; i < pts.GetLength(0); i++)*
    
  •    {*
    
  •      for(int j = 0; j < pts.GetLength(1); j++)*
    
  •      {*
    
  •        pts[i, j] = new Point3d(i * 10 + j, 0, 0);*
    
  •      }*
    
  •    }*
    
  •    GH_Structure<GH_Point> tree = new GH_Structure<GH_Point>();*
    
  •    for(int i = 0; i < pts.GetLength(0); i++)*
    
  •    {*
    
  •      GH_Path x = new GH_Path(i);*
    
  •      for(int j = 0; j < pts.GetLength(1); j++)*
    
  •      {*
    
  •        GH_Point y = new GH_Point(pts[i, j]);*
    
  •        tree.Append(y, x);*
    
  •      }*
    
  •    }*
    
  •    oTree = tree;*
    

What am I doing wrong?
Best wishes,
Oliver

The advice you got before in this thread (DataTree<T> or GH_Structure<T> in Visual Studio) assumed you were building a custom C# component in visual studio.

In a C# scripting component, I think you’ll have better luck with the DataTree structure rather than the GH_Structure<IGH_Goo>:

1 Like

Use DataTree<T> in C# scripting components. GH_Structure<T> was developed for use within compiled conde in VS. Probably the C# comp does not recognize that object and cant cast it successfully to be displayed in the viewport

with DataTree<T> you cans till use IGH_Goo derived types.

1 Like

Thank you very much for your answers!
I did not thought about that.
I have tried the code in visual studio studio and it has worked.
@andheum
Yes Im working in vs. I just wanted to try it in the Csharp scripting component first.
So for me, the GH_Structure is still the way to go.
Thank you very much.
Best wishes,
Oliver