I have a lisp routine that reads points from a CSV file and then adds a block at each point.
The problem is that this routine keeps skipping the first line of the CSV file.
Any idea what part of this code is doing that?
Thank you.
Code:
(defun C:IMPNT2 (/ str:list read:block a b c cm d s)
(defun str:list (str / b)
(foreach x (reverse (vl-string->list str))
(cond ((eq x 44) (setq b (cons (list x) b)))
(t
(if (not b)
(setq b (cons (list x) b))
(setq b (cons (cons x (car b)) (cdr b)))
)
)
)
)
(mapcar '(lambda (x) (vl-list->string (vl-remove 44 x))) b)
)
(defun read:block (s / e f)
(while (not f)
(if (setq e (entsel s))
(cond
((wcmatch (cdr (assoc 0 (entget (car e)))) "INSERT")
(setq f t)
)
(t (alert "Please select BLOCK object."))
)
(alert "Nothing selected, please try again.")
)
)
(vlax-ename->vla-object (car e))
)
(if (not SR:PATH)
(setq SR:PATH (getvar "dwgprefix"))
)
(if
(and (setq
a (getfiled "Select CSV File" SR:PATH "csv" 16)
)
(setq SR:PATH (strcat (vl-filename-directory a) ""))
(setq a (open a))
(setq c (while (setq b (read-line a))
(setq c (cons (str:list b) c))
)
)
(setq s (read:block "\nSelect Source Block : "))
)
(progn
(close a)
(setq cm (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setq d (ssadd))
(foreach x (cdr (reverse c))
(if (and (> (length x) 1)
(numberp (read (cadr x)))
(numberp (read (caddr x)))
(numberp (read (cadddr x)))
(setq bk (SR:INBLOCK
(list (* (atof (cadr x)) 1000.)
(* (atof (caddr x)) 1000.)
(* (atof (cadddr x)) 1000.)
)
(vla-get-effectivename s)
1
1
1
0
)
)
)
(ssadd (vlax-vla-object->ename bk) d)
)
)
(command "_.zoom" "_o" d "")
(setvar 'cmdecho cm)
(sssetfirst nil d)
)
)
(princ)
)
(SETQ SR:ACAD (VLAX-GET-ACAD-OBJECT)
SR:ACDOC (VLA-GET-ACTIVEDOCUMENT SR:ACAD)
SR:MODEL (VLA-GET-MODELSPACE SR:ACDOC)
)
(DEFUN SR:INBLOCK (POINT BLOCKNAME XSCALE YSCALE ZSCALE ROTATION)
(VLA-INSERTBLOCK
SR:MODEL
(VLAX-3D-POINT POINT)
BLOCKNAME
XSCALE
YSCALE
ZSCALE
ROTATION
)
)
(VL-LOAD-COM)
(PRINC)
(PRINC
(STRCAT
"\n:: Import Point Data.lsp ::"
"\n:: Created by Satish Rajdev | "
(MENUCMD "M=$(edtime,$(getvar,date),DDDD"," D MONTH YYYY)"
)
" ::"
"\n:: Type "IMPNT" to Import CSV ::"
)
)
(PRINC)