Thornley Posted May 21, 2009 Posted May 21, 2009 I wanted to know if anyone know a way to export lots mtext from a chart in AutoCAD (I am use Civil 3D 2008 currently) to a text documet (Excel, notepad, word . etc.), any suggestions? Thanks Quote
ReMark Posted May 21, 2009 Posted May 21, 2009 You'll probably need a Lisp routine to accomplish this task. Start with an Internet search based upon "MText"+"export"+"lisp" and see what comes up. Quote
Thornley Posted May 21, 2009 Author Posted May 21, 2009 Thanks ReMark, I actually found a good one just before you posted that. Thanks tho for the help.. Quote
ReMark Posted May 21, 2009 Posted May 21, 2009 You're welcomed Thornley. You're also pretty darn quick. Would you mind telling us a little bit about what you found? Sharing knowledge is what CADTutor is all about. Plus a large dose of Help to go with it. Know what I mean? Quote
Srajcka Posted September 5, 2011 Posted September 5, 2011 Thanks ReMark, I actually found a good one just before you posted that. Thanks tho for the help.. And what did you find, couse im look to somethink like this too Quote
irneb Posted September 5, 2011 Posted September 5, 2011 You might want to have a look at the links to other threads in the "Similar Threads" at the bottom of this page. Quote
fuccaro Posted September 5, 2011 Posted September 5, 2011 One of the oldest Lisp routine in this forum: http://www.cadtutor.net/forum/showthread.php?79-Exporting-Text Quote
irneb Posted September 6, 2011 Posted September 6, 2011 OK, here's my try which works for MText as well and surrounds each MText with page-break (form-feed) characters to distinguish from normal DTexts. Just comment out those lines if you don't want that (search the code for Page Break). It also provides an option to sort the text as selected (default), to Left, to Right, Up, Down, or as Created (using the handle code): (vl-load-com) ;; Convert selection set to list of dxf codes (defun ss->dxflst (ss / lst n) (if (and ss (setq n (sslength ss))) (while (> (setq n (1- n)) -1) (setq lst (cons (entget (ssname ss n)) lst)) ) ) lst ) ;; Multiple assoc on multiple keys (defun MMAssoc (keys lst / pair return) (foreach item lst (if (vl-position (car item) keys) (setq return (cons item return)) ) ) (reverse return) ) ;;; --------------------------------------------------------------------------------------- ;;; Convert a base into an integer ;;; --------------------------------------------------------------------------------------- (defun Base->Int (s b / i m ex) (or *digits* (setq *digits* (vl-string->list "0123456789ABCDEFGHIJKLMNOPQSTUVWXYZ"))) (setq m (wcmatch s "-*") s (vl-string->list (vl-string-left-trim "-+" s)) i 0.0 ex 0 ) (while s (setq i (+ (* i b) (vl-position (car s) *digits*)) s (cdr s) ) ) (fix (if m (- i) i ) ) ) ;; Export selection set to file and sort by option (defun TxtExp (ss fn sort / lst f) (if (and (setq lst (vl-sort (ss->dxflst ss) (cond ((eq sort "Selected") '(lambda (a b) nil)) ((eq sort "Left") '(lambda (a b) (< (cadr (assoc 10 b)) (cadr (assoc 10 a))))) ((eq sort "Right") '(lambda (a b) (> (cadr (assoc 10 b)) (cadr (assoc 10 a))))) ((eq sort "Up") '(lambda (a b) (> (caddr (assoc 10 b)) (caddr (assoc 10 a))))) ((eq sort "Down") '(lambda (a b) (< (caddr (assoc 10 b)) (caddr (assoc 10 a))))) ((eq sort "Created") '(lambda (a b) (> (Base->Int (cdr (assoc 5 b)) 16) (Base->Int (cdr (assoc 5 a)) 16))) ) ) ) ) (setq f (open fn "w")) ) (progn (foreach entity lst (cond ((eq (cdr (assoc 0 entity)) "TEXT") (princ (cdr (assoc 1 entity)) f) (princ "\r\n" f) ;Carriage Return + Line Feed ) ((eq (cdr (assoc 0 entity)) "MTEXT") (princ (chr 12) f) ;Page break (foreach str (MMAssoc '(1 3) entity) (setq str (cdr str)) (while (vl-string-search "\\P" str) (setq str (vl-string-subst "\r\n" "\\P" str)) ) (princ str f) ) (princ "\r\n" f) ;Carriage Return + Line Feed (princ (chr 12) f) ;Page break ) ) ) (close f) ) ) ) (defun c:TxtExp (/ ss fn sort) (if (and (setq ss (ssget '((0 . "TEXT,MTEXT")))) (setq fn (getfiled "Select text file" (getvar 'DwgPrefix) "txt" (+ 1 4 16))) (progn (initget "Selected Right Left Up Down Created") (setq sort (cond ((getkword "Sort order as/to [selected/Right/Left/Up/Down/Created] <Selected>: ")) ("Selected") ) ) ) ) (TxtExp ss fn sort) ) (princ) ) 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.