Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert AutoCAD text to a .txt filew/ carriage return

6 REPLIES 6
Reply
Message 1 of 7
smokinjo68
1029 Views, 6 Replies

Convert AutoCAD text to a .txt filew/ carriage return

I am trying to take text from AutoCAD and convert it to a .txt file so I may put them into a Excel or Word document. I was wondering if there is a LISP program out there that may help.
6 REPLIES 6
Message 2 of 7
EC-CAD
in reply to: smokinjo68

You want both regular 'text' and 'mtext' exported ?
or, just regular 'text'. ?
What version Acad you running ?
Bob
Message 3 of 7
Anonymous
in reply to: smokinjo68

IF it's MTEXT, edit it copy everything, then paste in Excel or Word. If
it's not MTEXT use the express tool to make it so.




wrote in message news:4814048@discussion.autodesk.com...
>I am trying to take text from AutoCAD and convert it to a .txt file so I
>may put them into a Excel or Word document. I was wondering if there is a
>LISP program out there that may help.
Message 4 of 7
smokinjo68
in reply to: smokinjo68

I would like to get both exported. I am, at the moment, using ACAD 2002. I have tried to copy and paste regular text & Mtext and all I get in WORD or EXCEL is an image.
Message 5 of 7
Anonymous
in reply to: smokinjo68

wrote in message news:4814383@discussion.autodesk.com...
> I would like to get both exported. I am, at the moment, using ACAD 2002.
I have tried to copy and paste regular text & Mtext and all I get in WORD or
EXCEL is an image.


per your original request
>I am trying to take text from AutoCAD and convert it to a .txt file


(defun c:TextToFIle( / *error* allText lenTxt idx fName txtFile dName
thisTxtObj thisText HeaderText)
(vl-load-com)
(defun *error*(msg)
(if msg
(if txtFile
(progn
(close txtfile)
(setq txtFile nil)
(gc)
)
)
)
)
(setq allText(ssget"x"(list(cons 0 "MText,Text"))))
(if allText
(progn
(setq HeaderText "---Put what you want at top of file here---")
(princ(strcat(itoa(setq lenTxt(sslength allText)))" text objects to
export"))
(setq idx -1)
(setq fName(strcat(getvar"DwgPrefix")(setq
dName(vl-filename-base(getvar"Dwgname")))"-Text.txt"))
(setq txtFile(open fName "w"))
(write-line HeaderText txtFile)
(write-line (strcat "Text exported from " dname "\nProbably in reverse
order of creation ")txtFile)


(repeat lenTxt
(setq thisTxtObj
(vlax-ename->vla-object(ssname allText (setq idx(1+ idx))))
thisText (vla-get-textstring thisTxtObj))
(write-line thisText txtFile)
);repeat
(close txtFile)
(setq txtFile nil)
(gc)
(princ"\nDone writing to file")
);progn
);if text
(princ)
)
Message 6 of 7
smokinjo68
in reply to: smokinjo68

Thanks MP. It worked like a charm. Thanks everyone for thier help and feel free to copy the file from this board and pass it on. Have a Great Day all.
Message 7 of 7
Anonymous
in reply to: smokinjo68

wrote in message news:4814844@discussion.autodesk.com...
> Thanks MP. It worked like a charm. Thanks everyone for thier help and feel
free to copy the file from this board and pass it on. Have a Great Day all.


yer welcome
:-)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost