algorithmic modeling for Rhino
These days I try to learn C#,but always meet some problems....
the following script has a Error:Object reference not sent to an instance of an object(in red color)
There are 3 reference points in pta,1 reference in ptOri,all they have been set to list of Point3d.
script following:
private void RunScript(List<Point3d> ptA, List<Point3d> ptOri, ref object A)
{
myPoint3d st = new myPoint3d(ptA);
A = st.X;
}
//<Custom additional code>
public class myPoint3d
{
private List<Point3d> p;
//**************************
public double X;
public double Y;
public double Z;
public myPoint3d(List<Point3d> ip)
{
p[0] = new Point3d(ip[0]);//error the following script has a Error:Object reference not
sent to an instance of an object
X = p[0].X;
Y = p[0].Y;
Z = p[0].Z;
}
}
Tags:
i have fixed this by searching the previous post.......
the keypoint is to use "new" to open a place to store the "p"
script:
private void RunScript(List<Point3d> ptA, List<Point3d> ptOri, ref object A)
{
myPoint3d st = new myPoint3d(ptA);
A = st.X;
}
//<Custom additional code>
public class myPoint3d
{
private List<Point3d> p ;
//**************************
public double X;
public double Y;
public double Z;
public myPoint3d(List<Point3d> ip)
{
p = new List<Point3d>(ip);
p[0] = ip[0];
X = p[0].X;
Y = p[0].Y;
Z = p[0].Z;
}
}
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by