raj patel Posted October 3, 2015 Posted October 3, 2015 i am new in autolisp please explain what the getexec, GetCell and putexcel command... (GetExcel "G:/FR_X/drline.csv" "drarc" "A20") what meaning of this command? also this code explain. (command "cutclip" ss33 "") (command "pasteclip" point1 "") Quote
rlx Posted October 3, 2015 Posted October 3, 2015 (edited) i am new in autolisp please explain what the getexec, GetCell and putexcel command... (GetExcel "G:/FR_X/drline.csv" "drarc" "A20") what meaning of this command? also this code explain. (command "cutclip" ss33 "") (command "pasteclip" point1 "") GetExcel looks like a lisproutine to retrieve data from cell "A20" , sheet "drarc" file "G:/FR_X/drline.csv" but as it is a csv file no telling exactly what the routine does because that all depends on the contents or format of the file. The other commands are partly standard autocad (google cutclip / pasteclip). Lisp routine has made a selection and saved this selection in variable ss33 , cuts it and pastes it (effectively move it) to coordinates saved by routine in variable 'point1'. gr. Rlx Edited October 4, 2015 by rlx Quote
BIGAL Posted October 5, 2015 Posted October 5, 2015 Getexel.lsp is a very good to/from excel & Autocad program, it may have a read csv as a option, the version I have does not, but it appears to be around 2008 version, perhaps their is a newer one. Overview of Main functions ;------------------------------------------------------------------------------- ; GetExcel - Stores the values from an Excel spreadsheet into *ExcelData@ list ; Syntax: (GetExcel ExcelFile$ SheetName$ MaxRange$) ; Example: (GetExcel "C:\\Folder\\Filename.xls" "Sheet1" "L30") ; GetCell - Returns the cell value from the *ExcelData@ list plus lots more options Quote
Lt Dan's legs Posted October 5, 2015 Posted October 5, 2015 (defun putexcel ( _file _lst flag / _excelapp _workbooks _ws _tbs _cells ) (if (and (setq _excelapp (vlax-get-or-create-object "Excel.Application")) (setq _workbooks (vlax-get _excelapp "Workbooks")) (or (and (findfile _file) (setq _ofile (vlax-invoke _workbooks "Open" _file)) ) (and (setq _ofile (vlax-invoke _workbooks 'Add)) (vlax-invoke _ofile 'Saveas _file) ) ) ) (progn (vlax-for w (vlax-get _excelapp "Sheets") (setq _tbs (cons w _tbs)) (cond ( (eq (vla-get-name w) _sheet) (setq _ws w) ) ) ) (if (and (or _ws (setq _ws (last _tbs))) (setq _cells (vlax-get _ws 'cells)) ) (foreach x _lst (apply (function vlax-put-property) (append (list _cells 'item) x) ) ) ) (vlax-invoke _ofile 'Save) (and flag (vlax-invoke _ofile 'close) (vlax-release-object _excelapp) ) ) ) ) (defun getexcel ( _file _sheet flag / _excelapp _workbooks _ws _tbs _cc _l ) (if (and (setq _file (findfile _file)) (setq _excelapp (vlax-get-or-create-object "Excel.Application")) (setq _workbooks (vlax-get _excelapp "Workbooks")) (setq _ofile (vlax-invoke-method _workbooks "Open" _file)) ) (progn (vlax-for w (vlax-get _excelapp "Sheets") (setq _tbs (cons w _tbs)) (cond ( (eq (vla-get-name w) _sheet) (setq _ws w) ) ) ) (if (or _ws (setq _ws (last _tbs))) (progn (setq _cc (vlax-get (vlax-get (vlax-get _ws 'UsedRange) 'Columns ) 'Count ) )(setq _n 0) ( (lambda ( / _v _tmpl ) (vlax-for x (vlax-get _ws 'UsedRange) (setq _v (vlax-get x 'value)) (cond ( (not _v)(setq _v "")) ( (numberp _v)(setq _v (rtos _v 2))) )(setq _tmpl (cons _v _tmpl)) (if (<= _cc (setq _n (1+ _n))) (progn (setq _l (cons (reverse _tmpl) _l)) (setq _tmpl nil _n 0) ) ) ) ) ) (and flag (vlax-invoke _ofile 'Close :vlax-false) (vlax-release-object _excelapp) ) ) ) ) ) (reverse _l) ) USE (putexcel "c:\\temp\\test.xls" (list (list 1 1 "Lt Dan's Legs") (list 6 2 "is the man!") (list 7 2 ":P") ) t ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.