Try this solution:
(defun KGA_Conv_EnameList_To_Pickset (lst / ret)
(setq ret (ssadd))
(foreach enm lst (if (not (vlax-erased-p enm)) (ssadd enm ret)))
(if (/= 0 (sslength ret)) ret)
)
(defun KGA_Data_FileRead (fnm / lst ptr str)
(if (setq ptr (open fnm "r"))
(progn
(while (setq str (read-line ptr))
(setq lst (cons str lst))
)
(close ptr)
(reverse lst)
)
)
)
(defun KGA_List_LastRemove (lst)
(reverse (cdr (reverse lst)))
)
; Every record in the CSV has to have 3 or 4 numerical fields: X,Y,Z[,Radius].
(defun CsvToSweep_ReadCsv (fnm)
(mapcar
(lambda (str / lst)
(setq lst (read (strcat "(" (vl-string-translate "," " " str) ")")))
(cond
((= 4 (length lst))
lst
)
((= 3 (length lst))
(append lst '(0.0)) ; Add default radius.
)
)
)
(KGA_Data_FileRead fnm)
)
)
; Return value: List of line and arc objects.
(defun CsvToSweep_CreatePath (spc datLst / linLst oldFilletrad ret)
(setq oldFilletrad (getvar 'filletrad))
(setq linLst
(mapcar
'(lambda (subA subB)
(vla-addline spc (vlax-3d-point (KGA_List_LastRemove subA)) (vlax-3d-point (KGA_List_LastRemove subB)))
)
datLst
(cdr datLst)
)
)
(setq ret
(cons
(car linLst)
(apply
'append
(mapcar
'(lambda (linA linB rad / enm)
(setq enm (entlast))
(setvar 'filletrad rad)
(command "_.fillet" (vlax-vla-object->ename linA) (vlax-vla-object->ename linB))
(if (not (equal enm (entlast)))
(list (vlax-ename->vla-object (entlast)) linB)
(list linB)
)
)
linLst
(cdr linLst)
(mapcar 'cadddr (cdr datLst))
)
)
)
)
(setvar 'filletrad oldFilletrad)
ret
)
(defun CsvToSweep_CreateSolid (spc pathLst rad / lst oldDelobj prof)
(setq oldDelobj (getvar 'delobj))
(setvar 'delobj 0)
(setq prof (vlax-vla-object->ename (vla-addcircle spc (vlax-3d-point 0.0 0.0 0.0) rad)))
(setq lst
(vl-remove
nil
(mapcar
'(lambda (path / enm)
(setq enm (entlast))
(command "_.sweep" prof "" (vlax-vla-object->ename path))
(if (not (equal enm (entlast)))
(entlast)
)
)
pathLst
)
)
)
(command "_.union" (KGA_Conv_EnameList_To_Pickset lst) "")
(entdel prof)
(setvar 'delobj oldDelobj)
)
(defun c:CsvToSweep ( / datLst diam doc fnm pathLst spc)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-endundomark doc)
(vla-startundomark doc)
(setvar 'cmdecho 0)
(if
(and
(setq fnm (getfiled "Select CSV file" "" "csv" 4))
(setq datLst (CsvToSweep_ReadCsv fnm))
(or
(not (vl-position nil datLst))
(prompt "\nError: invalid data ")
)
(setq diam (getdist "\nDiameter: "))
)
(progn
(setq spc ((if (= 1 (getvar 'cvport)) vla-get-paperspace vla-get-modelspace) doc))
(setq pathLst (CsvToSweep_CreatePath spc datLst))
(CsvToSweep_CreateSolid spc pathLst (/ diam 2.0))
(mapcar 'vla-delete pathLst)
)
)
(setvar 'cmdecho 1)
(vla-endundomark doc)
(princ)
)