CafeJr Posted January 9, 2015 Posted January 9, 2015 Guys, I need one help, someone knows one Lisp that I can get Texts (words) on AutoCad and export it in order of selection to a cell on Excel... Eg.: If I have 10 words, as I'll selecting it and when finished these then words will be exported to a cell (could be cels) to Excel. Thanks in advance... Quote
Tharwat Posted January 9, 2015 Posted January 9, 2015 Can you explain your goal with an example ? Are you wanting to select one by one to keep them in the same order exported to Excel ? Quote
BIGAL Posted January 9, 2015 Posted January 9, 2015 Getexecl.lsp it is a library of excel-autocad functions both ways. GetExcel.zip Quote
CafeJr Posted January 10, 2015 Author Posted January 10, 2015 (edited) Can you explain your goal with an example ?Are you wanting to select one by one to keep them in the same order exported to Excel ? In these picture In trying to clarify the task. Tharwat, the selection is one by one, because I have a Big drawing with a lot of information, and I need to follow the names and select it to export by selection order. To show the example I put A and B, but it's only to exemplify, not is necessary to work with two collumns or two line of cells, only get the words and export it to Excel in order of selection, it will help a lot. Edited January 10, 2015 by CafeJr Quote
CafeJr Posted January 10, 2015 Author Posted January 10, 2015 Getexecl.lsp it is a library of excel-autocad functions both ways. Thanks Bigal, I will try it too. Quote
BIGAL Posted January 10, 2015 Posted January 10, 2015 Your request is two parts, actually writing to excel is the easy bit and thinking about provide you always use A C C etc it can be done. Thinking about it now if you just make a list of text (A-1 B-1 B-3 A-2 ETC ) You can take 1st character and check if its A B C D etc and set column (asc(text)) last number A-23 = 23+row offset = cell row so if some missing will jump over blanks. B-23 = cell 2,27 Thanks to Lee-mac for this it will give a number as an answer. ; use say nth of your list of text selected (setq nthtext (nth x testlist)) ; to use (setq cellnum (Lm:parsenumbers nthtext)) ;;-------------------=={ Parse Numbers }==--------------------;; ;; ;; ;; Parses a list of numerical values from a supplied string. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) Quote
CafeJr Posted January 12, 2015 Author Posted January 12, 2015 Sorry Bigal, the text at AutoCad, isn't a specific address to Excel, it's any kind of text, to be exported to Excel in "any" cell. I didn't pay attention on AutoCad text that I wrote... similar a Excel cell address... Quote
pBe Posted January 12, 2015 Posted January 12, 2015 Getexecl.lsp it is a library of excel-autocad functions both ways. Cool lisp rouitne Quote
CafeJr Posted January 12, 2015 Author Posted January 12, 2015 Getexecl.lsp it is a library of excel-autocad functions both ways. Bigal, I don't know why, but I loaded the Getexcl lisp but it doesn't work, the command isn't recognized. I did it in two AutoCad softwares, 2012 and 2013 versions... Quote
Tharwat Posted January 12, 2015 Posted January 12, 2015 Bigal, I don't know why, but I loaded the Getexcl lisp but it doesn't work, the command isn't recognized. I did it in two AutoCad softwares, 2012 and 2013 versions... The GetExcel.lsp is a function to deal to Excel files that release after the year 2003 and which their extension files would be formatted to .xls and xlsx ... etc so this function alone does not help you with any . Anyway , I have a plan to write a program with a dialog box to obtain the selected text strings before exporting them to txt format or Excel file with a format .csv . Would this be suitable for your needs ? I am busy at the moment but would write it since that I think it would be handy program in general . Tharwat Quote
CafeJr Posted January 13, 2015 Author Posted January 13, 2015 Thank you Tharwat... I don't know if it's simple, but the idea is, is only collect a spread texts (words) in a drawing in order of selection... to export it to Excel. Quote
Tharwat Posted January 13, 2015 Posted January 13, 2015 Thank you Tharwat... I don't know if it's simple, but the idea is, is only collect a spread texts (words) in a drawing in order of selection... to export it to Excel. Try this program and let me know . Note: At the end of selecting texts , just press enter and type ( n ) or ( no ) to display the dialog for the last process . (defun c:Test (/ *error* _dialog dlg s name s l k save path o) ;;; Tharwat 13.01.2015 ;; (defun *error* (msg) (if (and dlg (findfile dlg)) (vl-file-delete dlg) ) (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (defun _dialog (/ id f) (cond ((not (and (setq dlg (vl-filename-mktemp nil nil ".dcl")) (setq f (open dlg "w")) (write-line "test : dialog {label = \"Test Strings\"; width = 40; : text { key = \"path\"; } spacer_1 ; : list_box { key = \"lst\"; height = 18;} : boxed_row { : button { label = \"Okay\"; key = \"oki\"; width = 12;} : button { label = \"Exit\"; key = \"esc\"; is_default = true; is_cancel = true; width = 12;} : button { label = \"Save to\"; key = \"sv\"; width = 12;} }}" f ) (not (close f)) ) ) (alert "Can't load the temporary file <!>") ) ((or (not dlg) (not (> (setq id (load_dialog dlg)) 0)) (not (new_dialog "test" id ) ) ) (princ "\n Can not load Dialog !") ) (t (start_list "lst") (mapcar 'add_list (reverse l)) (end_list) (mode_tile "oki" 1) (set_tile "lst" "0") (action_tile "sv" "(if (setq path (getfiled \"Save to\" (getvar 'DWGPREFIX) \"csv\" 1)) (progn (set_tile \"path\" path) (mode_tile \"oki\" 0)) (mode_tile \"oki\" 1))" ) (action_tile "oki" "(setq save t)(done_dialog)" ) (action_tile "esc" "(setq save nil)(done_dialog)") (start_dialog) (unload_dialog id) (vl-file-delete dlg) ) ) save ) (while (cond ((and (setq s (car (entsel "\n Pick Texts :"))) (wcmatch (cdr (assoc 0 (entget s))) "TEXT,MTEXT") ) (setq l (cons (cdr (assoc 1 (entget s))) l)) ) ((or s (not s)) (princ "\nInvalid Selection !! Select text ONLY ") (initget 6 "Yes No") (or (not (setq k (getkword "\n Missed !! Continue [Yes/No] <Yes> :"))) (eq k "Yes") ) ) ) ) (if (and l (setq save (_dialog)) (setq o (open path "w"))) (progn (mapcar '(lambda (x) (write-line x o)) (reverse l)) (close o) (princ "\n Well done ...") ) (princ "\n Exit by User ") ) (princ) ) Quote
CafeJr Posted January 13, 2015 Author Posted January 13, 2015 Woowwwww... He he he... Thanks Tharwat!... It Works as good as I need!!!... The unique "delay" that I have it's work with spreadsheets (by the number of usages), I'm thinking if has a way to fill up one spreadsheet only (I don't know), or using a Ram memory to copy these texts to paste one a cell in a Excel file open... It's that possible?... Quote
Tharwat Posted January 13, 2015 Posted January 13, 2015 Woowwwww... He he he... Thanks Tharwat!... It Works as good as I need!!!... I am happy that you liked the program The unique "delay" that I have it's work with spreadsheets (by the number of usages), I'm thinking if has a way to fill up one spreadsheet only (I don't know), or using a Ram memory to copy these texts to paste one a cell in a Excel file open... It's that possible?... I don't think that I got your point Quote
CafeJr Posted January 13, 2015 Author Posted January 13, 2015 Sorry, Let me try to explain!... Every time that I use it, I'll create a spreadsheet (it's ok, no problem, it's help a lot even why I need to rewrite the path on Excel!). It'll be used to follow electrical cables on a drawing, think in one electrical installation I have one point (origin) and a target of the cable (instruments on the field), so, I have to do these follow the path texts (address of electrical pipes or cable trays) to select where the cable pass through, are many cable to do it one by one, you got it?... Quote
seawind Posted May 22 Posted May 22 https://github.com/cadavre/MTZ-BA-11_lisp/blob/master/sz/LSP/getexcel.lsp getexcel.lsp Quote
BIGAL Posted May 23 Posted May 23 (edited) Not sure why you posted 9 years later, some people like me have developed more Excel functions and yes did start with getexcel.lsp. It was missing a couple of functions like get/put cell in a simplified way, getrange, add worksheet. Some have written high level code for speed that uses ARX functions called from lisp. Also big thanks to "Fixo" who wrote numerous Excel functions but is no longer with us, but you can find his code. Likewise can get Excel macro to draw cad objects. Latest task is LibreCalc functions, a free alternative to Excel. If you have a task ask. Edited May 23 by BIGAL Quote
Danielm103 Posted May 23 Posted May 23 Looks like good code, too bad it’s not being maintained. I didn’t check the forks though It’s cool to see source on GitHub, I think the lisp community should make more use of that 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.