Jump to content

Recommended Posts

Posted

Hi,

 

I have been searching for a lisp to export txt to excel.

Every lisp i've come across doesn't quite cut it.

We use AutoCAD LT 2013 and AutoCAD 07.

I want from every txt object (of a certain layer) the content + the X and Y coordinates.

 

Hope that you guys cab help me out.

 

Greetz,

 

TekenaarNL

Posted

AutoCAD LT doesn't support LISP, have you tried the DataExtract tools?

Posted

Hi,

 

I am using following routine in Autocad 2007 to export text with X & Y ID,

 

I hope this what you were looking for......:thumbsup:

 

(defun c:EXT (/ file dta p i)
;;; Creat CSV File
 (if (and
(setq
  file (open (getfiled "specify output file" "c:/" "csv" 1) "w")
)
(setq dta (ssget '((0 . "text,mtext"))))
     )

   (progn
     (write-line
"Sr No,X-Coord ,Y-Coord ,Text Value"
file
     )

     (princ "Initial number of point ID <")
     (princ no)
     (princ ">:")
     (setq nno (getint))
     (if (= nno nil)
(terpri)
(setq no nno)
     )
     (setq no (- no 1))

     (terpri)
     (princ
"Sr No  X-Coord   Y-Coord   Text   "
     )

     (repeat (setq i (sslength dta))

(setq eb (entget (ssname dta (setq i (1- i)))))

(setq p (cdr (assoc 10 eb)))

(setq txv (cdr (assoc 1 eb)))

(setq no (+ no 1))
(terpri)
(princ "  ")
(princ no)
(princ ".   ")
(princ (rtos (car p) 2 3))
(princ "  ")
(princ (rtos (cadr p) 2 3))
(princ "    ")
(princ txv)


;;;Output Details of CSV file
(write-line
  (strcat (rtos no 2 1)
	  ","
	  (rtos (car p) 2 3)
	  ","
	  (rtos (cadr p) 2 3)
	  ","
	  txv
  )
  file
)
     )
     (close file)
   )
 )
 (Princ)
)
(princ
 "\n 		    Type >EXT< to run this Routine"
)

Posted

I know that LT doesn't support LISP, that's wy I also use CAD 2007 (standard version).

The Dataextract in 2007 doesn't work.

None of the cad tools do the trick.

 

___________________________________________________________________________________________________________________________

AutoCAD LF 2013: G.204.0.0 SP2

AutoCAD 2007: V1.0

Posted

Thnx Satishrajdev !

 

It did the trick :D.

Posted

I m glad to heard that... :)

  • 2 years later...
Posted

Hi satishrajdev,

 

Thank you for the code!

This is what i need :)

 

Hope you have a good day, man

  • 2 years later...
Posted
Hi,

 

I am using following routine in Autocad 2007 to export text with X & Y ID,

 

I hope this what you were looking for......:thumbsup:

 

(defun c:EXT (/ file dta p i)
;;; Creat CSV File
 (if (and
(setq
  file (open (getfiled "specify output file" "c:/" "csv" 1) "w")
)
(setq dta (ssget '((0 . "text,mtext"))))
     )

   (progn
     (write-line
"Sr No,X-Coord ,Y-Coord ,Text Value"
file
     )

     (princ "Initial number of point ID <")
     (princ no)
     (princ ">:")
     (setq nno (getint))
     (if (= nno nil)
(terpri)
(setq no nno)
     )
     (setq no (- no 1))

     (terpri)
     (princ
"Sr No  X-Coord   Y-Coord   Text   "
     )

     (repeat (setq i (sslength dta))

(setq eb (entget (ssname dta (setq i (1- i)))))

(setq p (cdr (assoc 10 eb)))

(setq txv (cdr (assoc 1 eb)))

(setq no (+ no 1))
(terpri)
(princ "  ")
(princ no)
(princ ".   ")
(princ (rtos (car p) 2 3))
(princ "  ")
(princ (rtos (cadr p) 2 3))
(princ "    ")
(princ txv)


;;;Output Details of CSV file
(write-line
  (strcat (rtos no 2 1)
	  ","
	  (rtos (car p) 2 3)
	  ","
	  (rtos (cadr p) 2 3)
	  ","
	  txv
  )
  file
)
     )
     (close file)
   )
 )
 (Princ)
)
(princ
 "\n 		    Type >EXT< to run this Routine"
)

 

 

Fantastic code!

 

I'd like to insert just the selected texts from excel.

 

Is it possible?

 

Thanks

Posted

If you want direct to excel no problems, there is just so many examples out there just google Autocad to excel.

Posted
If you want direct to excel no problems, there is just so many examples out there just google Autocad to excel.

 

Thank you for advice.

 

I'm going to searching a code on the google.

  • 1 year later...
Posted
On 27/05/2013 at 15:04, satishrajdev said:

Hi,

 

I am using following routine in Autocad 2007 to export text with X & Y ID,

 

I hope this what you were looking for......:thumbsup:

 

 


(defun c:EXT (/ file dta p i)
;;; Creat CSV File
 (if (and
(setq
  file (open (getfiled "specify output file" "c:/" "csv" 1) "w")
)
(setq dta (ssget '((0 . "text,mtext"))))
     )

   (progn
     (write-line
"Sr No,X-Coord ,Y-Coord ,Text Value"
file
     )

     (princ "Initial number of point ID <")
     (princ no)
     (princ ">:")
     (setq nno (getint))
     (if (= nno nil)
(terpri)
(setq no nno)
     )
     (setq no (- no 1))

     (terpri)
     (princ
"Sr No  X-Coord   Y-Coord   Text   "
     )

     (repeat (setq i (sslength dta))

(setq eb (entget (ssname dta (setq i (1- i)))))

(setq p (cdr (assoc 10 eb)))

(setq txv (cdr (assoc 1 eb)))

(setq no (+ no 1))
(terpri)
(princ "  ")
(princ no)
(princ ".   ")
(princ (rtos (car p) 2 3))
(princ "  ")
(princ (rtos (cadr p) 2 3))
(princ "    ")
(princ txv)


;;;Output Details of CSV file
(write-line
  (strcat (rtos no 2 1)
	  ","
	  (rtos (car p) 2 3)
	  ","
	  (rtos (cadr p) 2 3)
	  ","
	  txv
  )
  file
)
     )
     (close file)
   )
 )
 (Princ)
)
(princ
 "\n 		    Type >EXT< to run this Routine"
)
 

 

 

On 27/05/2013 at 15:04, satishrajdev said:

Hi,

 

I am using following routine in Autocad 2007 to export text with X & Y ID,

 

I hope this what you were looking for......:thumbsup:

 

 


(defun c:EXT (/ file dta p i)
;;; Creat CSV File
 (if (and
(setq
  file (open (getfiled "specify output file" "c:/" "csv" 1) "w")
)
(setq dta (ssget '((0 . "text,mtext"))))
     )

   (progn
     (write-line
"Sr No,X-Coord ,Y-Coord ,Text Value"
file
     )

     (princ "Initial number of point ID <")
     (princ no)
     (princ ">:")
     (setq nno (getint))
     (if (= nno nil)
(terpri)
(setq no nno)
     )
     (setq no (- no 1))

     (terpri)
     (princ
"Sr No  X-Coord   Y-Coord   Text   "
     )

     (repeat (setq i (sslength dta))

(setq eb (entget (ssname dta (setq i (1- i)))))

(setq p (cdr (assoc 10 eb)))

(setq txv (cdr (assoc 1 eb)))

(setq no (+ no 1))
(terpri)
(princ "  ")
(princ no)
(princ ".   ")
(princ (rtos (car p) 2 3))
(princ "  ")
(princ (rtos (cadr p) 2 3))
(princ "    ")
(princ txv)


;;;Output Details of CSV file
(write-line
  (strcat (rtos no 2 1)
	  ","
	  (rtos (car p) 2 3)
	  ","
	  (rtos (cadr p) 2 3)
	  ","
	  txv
  )
  file
)
     )
     (close file)
   )
 )
 (Princ)
)
(princ
 "\n 		    Type >EXT< to run this Routine"
)
 

 

How can i use this code in autocad

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...