termal007 发表于 2022-7-6 08:29:14

How to Export text(Numbers) in

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

ReMark 发表于 2022-7-6 08:35:25

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.

fixo 发表于 2022-7-6 08:39:04

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");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

Organic 发表于 2022-7-6 08:47:09

What program were those cross sections generated in?

termal007 发表于 2022-7-6 08:49:43

hi
i can't run in autocad ; i typing in command is "tryit" when i loaded
what can i do ?
 
 

fixo 发表于 2022-7-6 08:52:28

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?

termal007 发表于 2022-7-6 09:01:30

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
 

fixo 发表于 2022-7-6 09:02:27

Ihad changed this line on your path within the code above, try again

fixo 发表于 2022-7-6 09:08:52

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 xsep)) 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");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

termal007 发表于 2022-7-6 09:13:17

:cry:does not work !!!!!!!
页: [1] 2
查看完整版本: How to Export text(Numbers) in