eInvalidInput error

eInvalidInput error

Anonymous
Not applicable
5,187 Views
2 Replies
Message 1 of 3

eInvalidInput error

Anonymous
Not applicable

 

Line line = new Line(ptStart, ptEnd);
Vector3d vec = new Vector3d();
Point3d ptd1 = new Point3d();
vec = line.GetFirstDerivative(ptd1).GetNormal(); //eInvalidInput

 

ptStart coordinate is (655275600.438987,36192616.8036762,0)

ptEnd coordinate is (655295053.399808,36189883.0214896,0)

 

 

Why am I always getting "eInvalidInput" error. Any help would be greatly appreciated.

 

0 Likes
Accepted solutions (2)
5,188 Views
2 Replies
Replies (2)
Message 2 of 3

BKSpurgeon
Collaborator
Collaborator
Accepted solution
 [CommandMethod("testDerivative")]
        public static void TestLine()
        {
            //// Your start points
            // Point3d p1 = new Point3d(655275600.438987, 36192616.8036762, 0);
            // Point3d p2 = new Point3d(655295053.399808, 36189883.0214896, 0);

            Point3d p1 = new Point3d(0, 0, 0);
            Point3d p2 = new Point3d(10, 0, 0);
            Point3d p3 = new Point3d(5, 0, 0);            

            using (Line ln = new Line(p1, p2))
            {
                Vector3d vec = new Vector3d();
                vec = ln.GetFirstDerivative(p3).GetNormal(); 
            }
        }

 

 

  • Try the above code - it works for me.
  • I think the error is coming because the p3 (i.e. the point supplied to the GetFirstDerivative method is not on the line itself. Solution is to: supply a point on the line.
  • Also I think you should dispose of your Line explicitly or use a `using` statement.. 
0 Likes
Message 3 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

It's because ptd1 (initialized to 0,0,0) does not lies on the line.

 

If you want to get the direction vector of the line, you can simply do:

vec = ptStart.GetVectorTo(ptEnd).GetNormal();

 or:

vec = (ptEnd - ptStart).GetNormal()

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub