@jobin.e ,
here a lisp command CSVIN to insert blocks from excel csv file. an sample of data format:-
; block name XCoords YCoords XScale YScale ZScale angle degrees
N arrow, 481124.241, 2761191.709, 1.0, 1.0, 1.0, 32.0
N arrow, 481135.811, 2761188.834, 1.0, 1.0, 1.0, 25.0
N arrow, 481113.401, 2761196.688, 1.0, 1.0, 1.0, 47.0
N arrow, 481093.631, 2761210.003, 1.0, 1.0, 1.0, 18.0
the omit the header from file. replace "N arrow" with your blocks name.
each record must have all these fields in this order.
wrap the following in lsp file and load it in autocad
(vl-load-com)
;; String to List - Lee Mac
;; Separates a string using a given delimiter
;; str - [str] String to process
;; del - [str] Delimiter by which to separate the string
;; Returns: [lst] List of strings
(defun LM:str->lst ( str del / pos )
(if (setq pos (vl-string-search del str))
(cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
(list str)
)
)
(defun c:csvin (/ _str->num _dtr ; local function
fdata fname f)
; anonymous functions
(setq _str->num (lambda (s) (atof (vl-string-trim " " s))))
(setq _dtr (lambda (s) (* (/ (_str->num s) 360.0) 2 pi)))
(vla-startUndoMark (vla-get-activedocument (vlax-get-acad-object)))
(cond
((not (setq fname (getfiled "Select csv data file" "" "csv" 8))))
((not (setq f (open fname "r")))
(vlr-beep-reaction)
(prompt (strcat "\nfail to open " fname))
)
( t
(while (setq line (read-line f))
(setq fdata (cons (LM:str->lst line ",") fdata))
)
(setq f (close f))
(foreach item (reverse fdata)
(entmake
(list
'(0 . "insert")
(cons '2 (nth 0 item))
(cons '10 (list (_str->num (nth 1 item)) (_str->num (nth 2 item))))
(cons '41 (_str->num (nth 3 item)))
(cons '42 (_str->num (nth 4 item)))
(cons '43 (_str->num (nth 5 item)))
(cons '50 (_dtr (nth 6 item)))
'(210 0.0 0.0 1.0)
); list
); entmake
); foreach
); case
); cond
(vla-endundoMark (vla-get-activedocument (vlax-get-acad-object)))
(princ)
); csvin