0 Members and 1 Guest are viewing this topic.
Whats happening is AutoCAD quark text\mtext that isn't left justified insertion point is stored in dxf code 11. the code doesn't account for this so when it finds text that isn't left justified their isn't any values for x y or z when its trying to write-line so it errors "stringp nil"updated the code to be a little more efficient and to account for this as well.Code - Auto/Visual Lisp: [Select](defun C:SMT (/ ss f txt LL UR str ent LLx LLy stx sty x y z) (vl-load-com) (setvar "osmode" 0) (if (setq ss (ssget '((0 . "*TEXT")))) (progn (if (setq f (open "C:\\txt2txt.txt" "w")) (progn (foreach txt (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-getboundingbox (vlax-ename->vla-object txt) 'minpt 'maxpt) (setq LL (vlax-safearray->list minpt) UR (vlax-safearray->list maxpt) str (cdr (assoc 1 (setq ent (entget txt)))) LLx (rtos (car LL) 2) LLy (rtos (cadr LL) 2) stx (rtos (- (car UR) (car LL)) 2) sty (rtos (- (cadr UR) (cadr LL)) 2) ) (if (eq (cdr (assoc 72 ent)) 0) (setq x (rtos (cadr (assoc 10 ent)) 2) y (rtos (caddr (assoc 10 ent)) 2) z (rtos (last (assoc 10 ent)) 2) ) (setq x (rtos (cadr (assoc 11 ent)) 2) y (rtos (caddr (assoc 11 ent)) 2) z (rtos (last (assoc 11 ent)) 2) ) ) (write-line (strcat X " " Y " " Z " " str " " LLx " " LLy " " stx " " sty) f) ) (close f) (Alert "txt2txt Created!") ) (prompt "\nUnable to create CSV file:") ) ) (prompt "\nNo Text Entity Selected: ") ) (setvar "osmode" 1) (princ))Also might want to update the location of where the file is being created.your documents folder Code - Auto/Visual Lisp: [Select](if (setq F (open (strcat (getenv "userprofile") "\\Documents\\txt2txt.txt") "w")) or in the same folder as the drawing. (must be saved)Code - Auto/Visual Lisp: [Select](if (setq F (open (strcat (getvar 'dwgprefix) "\\txt2txt.txt") "w"))