termal007 Posted December 27, 2011 Posted December 27, 2011 hi i want to export Numbers in CAD to Excel by easy method !!! i add one file attachment for EXample please see!!! this file is Poject Cross Section & i want to export text in layer "C-Road-SCTN-TITL" with text in layer "Are-Block" to different cells in Excel what can i do ? For Example : see excel file Sorce DWG : see DWg file example.xls part 1.dwg Quote
ReMark Posted December 27, 2011 Posted December 27, 2011 It appears that you have plain Text and MText objects on the two layers. I've seen at least three different lisp routines that claim to be able to export plain text to Excel but I have no idea how well they work. Quote
fixo Posted December 27, 2011 Posted December 27, 2011 (edited) Something wrong with your layers Here is quick and dirty lisp for your interest (vl-load-com) ;;*** list to csv readable string *** (defun list->csv(lst sep / join) ;;arguments ;; lst -list of string like: '("CENTER" "-4612.43" "5043.47" "1787.77") ;;sep - string (separator, i.e: ",") ;;return string like "CENTER,-4612.43,5043.47,1787.77" (setq join (apply 'strcat (mapcar '(lambda (x)(strcat x sep)) lst)) join (vl-string-right-trim sep join)) join ) (defun C:Tryit(/ contours datafile datalist fname mtext_list pt sectexts txs x) (command "_zoom" "_e") (if (setq sectexts (ssget "X" (list (cons 0 "mtext") (cons 8 "C-ROAD-SCTN-TITL") (cons 62 92) (cons 40 2.0) (cons 7 "Standard") (cons 1 "*+*") (cons 410 (getvar "ctab")) ) ) ) (progn (setq mtext_list (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex sectexts))) ) (setq contours (mapcar '(lambda (x) (if (setq pt (vlax-get x 'insertionpoint)) (cons (vlax-get x 'textstring) (list (list (- (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (- (cadr pt) 24)) (list (- (car pt) 24) (- (cadr pt) 24)) ) ) ) ) mtext_list ) ) (setq datalist (mapcar '(lambda (x) (cons (car x) (list (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block") (cons 410 (getvar "ctab")))) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block1") (cons 410 (getvar "ctab"))) ) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) ) ) ) contours ) ) (setq fname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv");<-- change on .xls ) (setq datafile (open fname "W")) (write-line "C-ROAD-SCTN-TEXT,are-block,are-block" datafile) (foreach record datalist (write-line (list->csv record ",") datafile) ) (close datafile) (getstring "\n\t\t *** Press Enter to open resulting file ***") (startapp "C:\\Program1\\Microsoft Office\\Office14\\EXCEL.EXE" (strcat "\"" fname "\"")) ) ) (princ) ) (prompt "\n\t\t >>> Start command with Tryit <<<") (prin1) Edited December 28, 2011 by fixo Quote
Organic Posted December 27, 2011 Posted December 27, 2011 What program were those cross sections generated in? Quote
termal007 Posted December 28, 2011 Author Posted December 28, 2011 hi i can't run in autocad ; i typing in command is "tryit" when i loaded what can i do ? Something wrong with your layersHere is quick and dirty lisp for your interest (vl-load-com) ;;*** list to csv readable string *** (defun list->csv(lst sep / join) ;;arguments ;; lst -list of string like: '("CENTER" "-4612.43" "5043.47" "1787.77") ;;sep - string (separator, i.e: ",") ;;return string like "CENTER,-4612.43,5043.47,1787.77" (setq join (apply 'strcat (mapcar '(lambda (x)(strcat x sep)) lst)) join (vl-string-right-trim sep join)) join ) (defun C:Tryit(/ contours datafile datalist fname mtext_list pt sectexts txs x) (command "_zoom" "_e") (if (setq sectexts (ssget "X" (list (cons 0 "mtext") (cons 8 "C-ROAD-SCTN-TITL") (cons 62 92) (cons 40 2.0) (cons 7 "Standard") (cons 1 "*+*") (cons 410 (getvar "ctab")) ) ) ) (progn (setq mtext_list (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex sectexts))) ) (setq contours (mapcar '(lambda (x) (if (setq pt (vlax-get x 'insertionpoint)) (cons (vlax-get x 'textstring) (list (list (- (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (- (cadr pt) 24)) (list (- (car pt) 24) (- (cadr pt) 24)) ) ) ) ) mtext_list ) ) (setq datalist (mapcar '(lambda (x) (cons (car x) (list (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block") (cons 410 (getvar "ctab")))) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block1") (cons 410 (getvar "ctab"))) ) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) ) ) ) contours ) ) (setq fname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv");<-- change on .xls ) (setq datafile (open fname "W")) (write-line "C-ROAD-SCTN-TEXT,are-block,are-block" datafile) (foreach record datalist (write-line (list->csv record ",") datafile) ) (close datafile) (getstring "\n\t\t *** Press Enter to open resulting file ***") (startapp "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE" (strcat "\"" fname "\"")) ) ) (princ) ) (prompt "\n\t\t >>> Start command with Tryit <<<") (prin1) Quote
fixo Posted December 28, 2011 Posted December 28, 2011 Working good on A2009 for me Perhaps, it is needs to change your Excel.exe path: mine is "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE" What is the error you have got? Quote
termal007 Posted December 28, 2011 Author Posted December 28, 2011 i take movie plaese see it and help me ; what can i do with error !! my Excel.exe path is "C:\Program1\Microsoft Office\Office14\EXCEL.EXE" plaease Help !! file download : http://www.mediafire.com/?cyuxi3ac98z3gy3 Working good on A2009 for mePerhaps, it is needs to change your Excel.exe path: mine is "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE" What is the error you have got? Quote
fixo Posted December 28, 2011 Posted December 28, 2011 I had changed this line on your path within the code above, try again Quote
fixo Posted December 28, 2011 Posted December 28, 2011 Just to avoid troubles with Excel, try it for the quick test It will output text file instead: Command :Txtin ;;*** list to csv readable string *** (defun list->csv(lst sep / join) ;;arguments ;; lst -list of string like: '("CENTER" "-4612.43" "5043.47" "1787.77") ;;sep - string (separator, i.e: ",") ;;return string like "CENTER,-4612.43,5043.47,1787.77" (setq join (apply 'strcat (mapcar '(lambda (x)(strcat x sep)) lst)) join (vl-string-right-trim sep join)) join ) (defun C:Txtin(/ contours datafile datalist fname mtext_list pt sectexts txs x) (command "_zoom" "_e") (if (setq sectexts (ssget "X" (list (cons 0 "mtext") (cons 8 "C-ROAD-SCTN-TITL") (cons 62 92) (cons 40 2.0) (cons 7 "Standard") (cons 1 "*+*") (cons 410 (getvar "ctab")) ) ) ) (progn (setq mtext_list (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex sectexts))) ) (setq contours (mapcar '(lambda (x) (if (setq pt (vlax-get x 'insertionpoint)) (cons (vlax-get x 'textstring) (list (list (- (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (cadr pt)) (list (+ (car pt) 24) (- (cadr pt) 24)) (list (- (car pt) 24) (- (cadr pt) 24)) ) ) ) ) mtext_list ) ) (setq datalist (mapcar '(lambda (x) (cons (car x) (list (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block") (cons 410 (getvar "ctab")))) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) (if (setq txs (ssget "wp" (cdr x) (list (cons 0 "text") (cons 8 "are-block1") (cons 410 (getvar "ctab"))) ) ) (vlax-get (vlax-ename->vla-object (ssname txs 0)) 'textstring) "" ) ) ) ) contours ) ) (setq fname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".txt");<-- change on .xls ) (setq datafile (open fname "W")) (write-line "C-ROAD-SCTN-TEXT,are-block,are-block" datafile) (foreach record datalist (write-line (list->csv record "\t") datafile) ) (close datafile) (getstring "\n\t\t *** Press Enter to open resulting file ***") ;;(startapp "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE" (strcat "\"" fname "\"")) (startapp "NOTEPAD.EXE" (strcat "\"" fname "\"")) ) ) (princ) ) (prompt "\n\t\t >>> Start command with Txtin <<<") (prin1) (vl-load-com) Quote
Organic Posted December 28, 2011 Posted December 28, 2011 Both lisps work fine for me on the sample data file. Termal, have a read of http://lee-mac.com/runlisp.html From the look of that video you posted it doesn't look like you are saving the lisp/running it properly. Quote
termal007 Posted December 28, 2011 Author Posted December 28, 2011 thanks ; i am realy Sorry !! Please accept my apologies . but some sections are 2 area and this lisp are typeing one area ; what can i do typing two areas in note pad ? Quote
fixo Posted December 28, 2011 Posted December 28, 2011 Perhaps, change layer names in selection filter , I was using "are-block" twice in there Sorry I'm busy now Quote
termal007 Posted December 29, 2011 Author Posted December 29, 2011 thanks guy ; thank u so much ! 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.