# IGoal Initialisation Point vs Index

IGoal Object initialisation is forcefully asking integer point references instead of the point3d arguments even if I explicitly declare the types. Should it except Points3d as in the example declaration below, or should one always work with point indices when dealing with goals?

I am assuming that integer type initialisation is referring to the point index from the discretised & duplicate free point system. How can I convert a point to the Physical System point index?

How I am tying to calling it:

``````IGoal myHinge = Hinge((point3d)P1, (point3d)P2,(point3d)P3,(point3d)P4, (double)ra, (double)k)
``````

Relevant initialisation

``````namespace KangarooSolver.Goals
{
public class Hinge : GoalObject
{
public double Strength;
public double RestAngle;

public Hinge();
public Hinge(int P0, int P1, int P2, int P3, double RA, double k); //Visual studio interpreting that I am referring to this initialisation
public Hinge(Point3d P0, Point3d P1, Point3d P2, Point3d P3, double RA, double k); //Even if I am aiming to use this.

public override void Calculate(List<Particle> p);
}
}
``````

@DanielPiker

You can create goals using either Point3d or integer PIndex.
If using Point3d though, you need to also assign the indexing before calling Step.
The AssignPIndex method is usually the easiest way of doing this automatically (and what is called in the standard non-scripting solver component).

See here for one example:

1 Like

Yes, I indeed was working under the impression that both could be used, thanks for confirming. My issue is that Visual Studio complains to me that it is expecting (int) when I clearly give it the (Point3d) arguments preventing me from creating them. In the hinge example above I get this:

It seemingly is forcefully using the PIndex initialisation

I think I found a work around by doing the following. Would this be equivalent to the example?

``````KangarooSolver.Goals.Hinge G = new KangarooSolver.Goals.Hinge()
{
PPos = new Point3d[] { P1[i], P2[i], P3[i], P4[i] },
Strength = (double)1,
RestAngle = (double)Math.PI / 2
};
``````

and then use the PS.AssignPIndex to replace the Points with the index reference as you instructed before Stepping the solver.

Still, I am unsure why the initialisation I was using before did not work for me, but it seems this does the job.

That seems odd. When you try to create a new Hinge instance in VS, do you see the 3 ways of initialising like this?: 1 Like

Yes I do, that is why it is so weird that it complains.

Resolved: I updated RhinoCommon/Grasshopper to the latest version (7.24.22308) and the initialisation with point3d worked.