C# Kangaroo Custom Goal - increment/decrement Anchor points Live

LiveAddingAnchorPoints.gh (15.3 KB)

Hello everyone :slight_smile:
Quiet strange to write in that brand new grasshopper forum but lets give it a try ^^

So the problem I have is quiet simple and could be interresting for other people I guess.
I’m incrementing points into a list but when come the moment to remove them they just continue incremeting.

//Custom Code
    for (int i = 0; i < iPoints.Count; i++)
    {
      goals.Add(new Anchor(iPoints[i], 1000.0));
    }
    Goals = goals;
 //Custom Code 
    
 //Additional Code   
    List<IGoal> goals = new List<IGoal>();
    List<Point3d> points = new List<Point3d>();
 //Additional Code   

The idea is to make a C# component to send custom goals anchor points to Kangaroo Solver that you can change whenever you want.

Of course it is possible to do that with kangaroo components, but the idea is to implement that feature in a bigger script after.

Better an exemple than a big explanation : Just open the .gh file everythink will be more clear

Thanks for your attention :slight_smile:

If you declare your goals and points list not in additional code but after runscript it should be added to list once. Or you need to use goals.Clear() points.Clear() in runscript to overwrite previous data

^^ the solution was there just in front of my nose :smiley:
Thanks a lot Petras.

//Custom code
List<IGoal> goals = new List<IGoal>();
List<Point3d> points = new List<Point3d>();

for (int i = 0; i < iPoints.Count; i++)
{
  goals.Add(new Anchor(iPoints[i], 1000.0));
}
Goals = goals;
//Custom code