Hi,
I have an issue with a lisp and am looking for some assistance. The lisp is currently reporting an error.
Click the point you want: ; error: too few arguments
It asks for a point and then puts the "Closest point" (a grid column) from the *.csv into mtext box.
It should also put the distance to the "Closest point" below that but it seems to be failing here.
Capture 1.jpg attached is what i am looking for.
Capture 2.jpg attached is what i am getting.
I have also attached the *.csv i am using and lsp file
Below is the current code I am using. If anyone can help that would be great.
Thanks in advance.
(defun c:yeah ( / pnt file pntlist bob apntlst pntlst sttext)
(if (setq pnt (getpoint "\nClick the point you want: "))
(progn
(findfile "GRIDLINE.csv")
(setq file (open "C://GRIDLINE.csv" "r"))
(setq pntlst (list ""))
(while (setq bob (read-line file))
(if (not (vl-string-search "GRID" (strcase bob)))
(progn
(setq apntlst (list (substr bob 1 (vl-string-search "," bob)) (list (atoi (substr bob (+ 2 (vl-string-search "," bob)) (- (vl-string-search "," bob (vl-string-search "," bob)) 1))) (atoi (substr bob (+ 2 (vl-string-position (ascii ",") bob nil t)) (strlen bob))) 0)))
(setq pntlst (vl-remove "" (cons apntlst pntlst)))
)))
(if pntlst
(progn
(setq pntlst (vl-sort pntlst '(lambda (z a) ( < (distance pnt (cadr z)) (distance pnt (cadr a))))))
(setq sttext (strcat "Gridline Reference \\P" "Closest point: " (caar pntlst)))
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(sb-mktxt2 sttext pnt)
(setvar "osmode" os)
))
))
)
(defun sb-mktxt2 (text pnt / )
(vlax-put-property (vla-addMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point pnt) 0 text))
)