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

Exporting plines and texts

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
333 Views, 5 Replies

Exporting plines and texts

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)

 

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

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

 

Message 3 of 6
Anonymous
in reply to: Anonymous

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

 

Message 4 of 6
Hallex
in reply to: Anonymous

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'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 6
Anonymous
in reply to: Hallex

Thanks.

It does the purpose.

Message 6 of 6
Hallex
in reply to: Anonymous

Glad to help,

Cheers Smiley Happy

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

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

Post to forums  

Autodesk Design & Make Report

”Boost