Yesterday I post the message "Exporting pline and text" which turned out to work realy well.
However I need something else...
I need to select several plines and export their vertexes (as it is already done) BUT I also need to select SEVERAL texts and export them as well as their insertion point coordinates.
I tried with the code below but without any success... It gives the error "; error: ActiveX Server returned the error: unknown name: "TEXT"" This happens after selecting some texts and hiting enter.
Can anyone help me?
Here is the code:
(defun c:zi5 ( / f i o s ss obj objdata texto texto_f nomebase nome_zi tx1 iPt) (vl-load-com) (setq nomebase (getstring "\nEnter name for file:")) (setq nome_zi (strcat "D:" nomebase "_zi.txt")) (princ "Select your plines...") (if (and (setq s (ssget '((0 . "LWPOLYLINE")))) (setq f (open nome_zi "w")) ) (progn (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (princ (apply 'strcat (vl-list* "\n" ( (lambda ( a ) (a (vlax-get o 'coordinates))) (lambda ( b ) (if b (cons (strcat "+"(rtos (car b)) "," (rtos (cadr b)) "\t") (a (cddr b)) ) ) ) ) ) ) f ) ) ) ) (princ "Select your texts...") (if (and (setq s (ssget '((0 . "TEXT")))) ) (progn (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (princ (apply 'strcat "\n" (vlax-get o 'Text) ( (lambda ( a ) (a (vlax-get o 'coordinates))) (lambda ( b ) (if b (cons (strcat "+"(rtos (car b)) "," (rtos (cadr b)) "\t") (a (cddr b)) ) ) ) ) ) f ) ) ) ) (close f) ) (princ)
Solved! Go to Solution.
I've just edited a few more lines at the end but again without success...
Any help?
(if (and (setq s (ssget '((0 . "TEXT")))) ) (progn (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (princ (apply 'strcat "\n" (vlax-get-property o 'TextString) "\n" (vl-list* "\n" ( (lambda ( a ) (a (vlax-get o 'InsertionPoint))) (lambda ( b ) (if b (cons (strcat "+" (rtos (car b)) "," (rtos (cadr b)) "\t") (a (cddr b)) ) ) ) ) ) ) f ) ) ) )
Just got the solution!!!!
Just the bit of code which concerns to the text and its insertion point:
(setq ss (ssget '((0 . "*TEXT")))) (repeat (setq i (sslength ss)) (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq pt (vlax-get o 'Insertionpoint)) (setq area (strcat (vla-get-textstring o) (strcat "\t+" (rtos (car pt)) "," (rtos (cadr pt))) ) ) (princ (strcat area "\n") f) )
See if this helps
(defun c:zi5 ( / f i nomebase nome_zi o pt s) (vl-load-com) (setq nomebase (getstring "\nEnter name for file:")) (setq nome_zi (strcat "D:" nomebase "_zi.txt")) (princ "Select the texts and plines...") (if (and (setq s (ssget '((0 . "LWPOLYLINE,TEXT")))) (setq f (open nome_zi "w")) ) (progn (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (ssname s (setq i (1- i))))) (if (eq "AcDbText" (vla-get-objectname o)) (progn (setq pt (vlax-get o 'insertionpoint)) (write-line (strcat (vlax-get-property o 'TextString) "\t" "+" (rtos (car pt)) "," (rtos (cadr pt)) "," (rtos (caddr pt))) f) ) (princ (apply 'strcat (vl-list* "\n" ((lambda (a) (a (vlax-get o 'coordinates))) (lambda (b) (if b (cons (strcat "+" (rtos (car b)) "," (rtos (cadr b)) "\t") (a (cddr b)) ) ) ) ) ) ) f ) ) ) ) ) (close f) (princ) )
~'J'~