C# - Get curve result from Spring and other goals

i have 4 circle near together
i set curveColid to each other truly
i set Spring between them
but the Spring goal for input ask me 2 Point3D or line
by the way i set points of my 4 circles to the spring
when i run Step
nothing happen

when i search in solver moves i can see the moves but it doesn’t automaticaly set on my CurveColid
and didn’t show me a line as spring looklike Grasshopper

you know what
if at pure C# we cant get Graphical result like grasshopper , can i stick my curveColid to point of Spring

what is Lenght Goal in grasshopper at the C# code i use Spring it was true ?

how we can detect whats the Solver output Type
at my last topic dear @DanielPiker set List of Curve for answering me
all of the Output is by this type ?

private void RunScript(List<Circle> cirs, ref object Circles, ref object Springs, ref object Anchor)
  var PS = new PhysicalSystem();
  var Goals = new List<IGoal>();
  var crvs = cirs.Select(cir => cir.ToNurbsCurve()).Cast<Curve>().ToList();
  var plns = cirs.Select(cir => cir.Plane).ToList();
  Goals.Add(new CurveCollide(crvs, plns, new List<Curve>(), Plane.WorldXY, 10));
  for(var i = 0; i < cirs.Count; i++)
    for(var j = i + 1; j < cirs.Count; j++)
      Goals.Add(new Spring(cirs[i].Center, cirs[j].Center, 0, 0.1));
  Goals.Add(new Anchor(cirs[0].Center, 1000));
  foreach(IGoal G in Goals)
    PS.AssignPIndex(G, 0.0001);
  int counter = 0;
  double threshold = 1e-6;
    PS.Step(Goals, true, threshold);
  } while(PS.GetvSum() > threshold && counter < 100);
  var outputs = PS.GetOutput(Goals);
  Circles = outputs[0];
  var springs = new List<Line>();
  for(var i = 1; i < outputs.Count - 1; i++)
    springs.Add((Line) outputs[i]);
  Springs = springs;
  Anchor = outputs[outputs.Count - 1];

CurveCollide.gh (5.2 KB)


thank you at soon i test it in My pure C# rhino plugin

@Mahdiar whats is the rule of the out put?
first of list is Curve
from 1 to end of list -1 is line ?
how can i understand what is the output type
in C# not grasshopper ( i’m plugin programmer )

The PS.GetOutput returns a list of objects corresponding to list of input Goals.


ok you add 4 cuves
but return one curve array
what can i understand this solution
in C# we havent Curve array for input goal and we should add one by one
and you do this by helping Grasshopper
ok so now - we add 4 goals for circles and return just one Curve array in one element of GetOutput() method
after it exactly Curves method add springs one after one and i get a list of lines in many element of GetOutput() method
its very hard to understand

Each goal can return an object when its Output method is called.
This object could be a single item, a list or an array.
For example, a Spring(Length) goal returns the line between its endpoints

Also many goals simply return null as their output.
When you call GetOutput for your list of goals, you get a list containing the result of the Output method of each of the goals in the list.