Hi everyone,
it’s been so long since I wrote in C# in the GH component that I forgot how to make Data persistent.
I am creating points in a class and want to move them. I know it is happening, because when I change the slider, the wavesystem class get created again and thus the points. In VS I would create a private class instance outside the solve instance. How in the GH-C# Component?
Why am I so forgetful and stupid?
{
var ws = new Wavesystem();
for (int i = 0; i < loops; i++)
{
ws.Move();
}
var pts = new List<Point3d>();
for (int i = 0; i < 10; i++)
{
pts.Add(ws.drops[i]);
}
A = pts;
}
// <Custom additional code>
public class Wavesystem
{
public Random random = new Random();
public List<Point3d> drops = new List<Point3d>();
public Wavesystem()
{
for (int i = 0; i < 10; i++)
{
drops.Add(GetRandomPointXYZ());
}
}
public void Move()
{
for (int i = 0; i < 10; i++)
{
drops[i] += new Vector3d(0, 0, -0.01);
}
}
public Point3d GetRandomPointXYZ()
{
return(new Point3d(random.NextDouble(), random.NextDouble(), random.NextDouble()));
}
}
Thanks everybody for helping …
230812_Debug.gh (3.9 KB)