- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All
I am writing a fx in Autolisp to calculate and return the distances (D1,D2,...Dn) of a point defined by xo,yo to a list of points defined by a list (x1,y1,x2,y2,...xn,yn) But in the Vlisp editor, adding the watch, i keep seeing that the function have its arguments always nil:
I hope I get much needed advice on this board.
; A helper function to calculate the Pythagorian distance. Tested.
(defun DisPythagor(x1,y1,x2,y2/)
(setq xx (- x1 x2))
(setq xx (* xx xx))
(setq yy (- x1 x2))
(setq yy (* yy yy))
(setq Pythagore (sqrt (+ xx yy)))
); function
; the function part that is making the error of always having xo, yo and xiyiList as nil:
(defun manyDist( xo,yo,xiyiLst)
(setq Dislist nil)
(setq i 0)
(setq test (length xiyiLst))
(alert (rtos test))
(while (< i (/ (length xiyiLst) 2))
; works each two numbers together:
(setq xi (nth i numlist))
(setq yi (nth (+ i 1) numlist))
(setq Di (DisPythagor xo,yo,xi,yi))
; now aSdds this Di the assembled list:
(setq Dislist (append Dislist (list Di)))
(+ i 2) ; advances the counter
); while
(setq Dislist Dislist) ; to make it the last thing happening
); function
; the main calling the function above:
(setq PtList (list 3 3 1 1 2 2 3 3))
(setq x 0)
(setq y 0)
(setq Disliste (manyDist x,y,PtList))
(princ Disliste)
Solved! Go to Solution.