Listen, I did say forget about CSV did I?
I take that back, We are still going to use CSV but from first tab "3D_poly_working" so the concatenation will be done within the lisp code.
Reading directly from Excel takes a lot longer that i expected.
This code will read the CSV file from the attached files. I copied the values from "Final for CSV - to run LISP" tab and paste it on notepad then save the file as third tab.CSV. Keeping in mind this is after you do all this:
...From the source file, I will get 3D poly line coordinates only then I used to add text before those coordinate "command.."3D poly... etc (using concatenate function in excel). and tag for that 3D polyline, regarding layer I will add manually i.e. one new layer for this 3D polyline which to be drawn...
Run this lisp and use third Tab.CSV as source: (approximately 10 seconds)
(defun c:i3DPL ( / *error* osm tag)
(defun *error* (msg)
(if osm
(setvar 'OSMODE osm)
)
(cond ((not msg))
((member msg '("Function cancelled" "quit / exit abort")))
((princ (strcat "\n** Error: " msg " ** ")))
)
(princ)
)
(setq osm (getvar 'OSMODE))
(setvar 'OSMODE 0)
(if (not (tblsearch "APPID" "Ishwinder_LineTag"))
(regapp "Ishwinder_LineTag")
)
(defun tag (name)
(entmod (append (entget (entlast)) (list (list -3 (list "Ishwinder_LineTag" '(1002 . "{") (cons 1000 name) '(1002 . "}"))))))
)
(if (setq theCSVSoure (getfiled "Select CSV file" (getvar 'dwgprefix) "csv" 16))
(progn
(setq opencsvfile (open theCSVSoure "r"))
(while (setq RowContent (read-line opencsvfile))
(Eval (read RowContent)))
(close opencsvfile)
)
) (*error* nil)
(princ "Type i3DPL to run the lisp.")
(princ)
)
command: i3DPL
And now for the other code
I open the excel file and save the "3D_poly_working" as CSV (Comman Delimited) first tab.csv and nothing else. The program will read the
first tab.csv ignoring rows 1 to 7 and columns W onward.
Run this lisp and use first tab.csv as source: (approximately 10 seconds)
(defun c:FirstTabCSV (/ _delimiter _coordinates tag theCSVSoure allTheDataNeeded openedCSVFile a b)
(defun _delimiter (str md / d l str)
(if (listp str)
(apply 'strcat
(cons (car str)
(mapcar '(lambda (r) (strcat (chr md) r))
(cdr str)
)
)
)
(progn
(while (setq d (vl-string-position md str nil T))
(setq l (cons (substr str (+ 2 d)) l)
str (substr str 1 d)
)
)
(cons str l)
)
)
)
(defun _coordinates (lst indx)
(mapcar '(lambda (l) (distof (nth l lst)))
(list indx (1+ indx) (+ 2 indx))))
(if (not (tblsearch "APPID" "Ishwinder_LineTag"))
(regapp "Ishwinder_LineTag")
)
(defun tag (name)
(entmod (append (entget (entlast)) (list (list -3 (list "Ishwinder_LineTag" '(1002 . "{") (cons 1000 name) '(1002 . "}"))))))
)
(foreach layers '(("_End2_Text" 43)
("_Inst_Text" 33)
("_3D_poly" 82)
("_JB_Text" 54))
(if (not (tblsearch "Layer" (car layers)))
(entmake (list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 2 (car layers))
(cons 62 (cadr layers))
(cons 70 0))))
)
(if (setq allTheDataNeeded nil
theCSVSoure (getfiled "Select CSV file" (getvar 'dwgprefix) "csv" 16))
(progn
(setq openedCSVFile (open theCSVSoure "r"))
(while (setq a (read-line openedCSVFile))
(setq b (_delimiter a 44))
(if (vl-every '(lambda (n)
(numberp (read (nth n b)))) '(2 3 4))
(setq allTheDataNeeded (cons b allTheDataNeeded)))
)
(close openedCSVFile)
(setvar 'clayer "_3D_poly")
(foreach data allTheDataNeeded
(command "_3DPOLY")
(foreach pt (list (setq pt1 (_coordinates data 7))
(_coordinates data 10)
(_coordinates data 13)
(_coordinates data 16)(_coordinates data 19))
(command "_non" pt))
(command "")
(tag (cadr data))
(entmakex
(list (cons 0 "TEXT")
(cons 10 pt1)
(cons 40 67.5)
(cons 8 "_Inst_Text")
(cons 1 (strcat (cadr data) "_" (nth 4 data)))))
(entmakex
(list (cons 0 "TEXT")
(cons 10 (list (Car pt1)(+ 67.5 (cadr pt1)) (caddr pt1)))
(cons 40 54.0)
(cons 8 "_End2_Text")
(cons 1 (strcat (cadr data) "_" (nth 4 data)))))
)
)
)
(princ)
)
command: FirstTabCSV
We may need to modify the code later, I;m not sure about the source for TEXT at "_JB_Text" layer .
HTH