Jump to content

Recommended Posts

TekenaarNL

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

Link to post
Share on other sites
satishrajdev

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

Link to post
Share on other sites
TekenaarNL

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

Link to post
Share on other sites
  • 2 years later...
  • 2 years later...
Madruga_SP
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

Link to post
Share on other sites
Madruga_SP
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.

Link to post
Share on other sites
  • 1 year later...
Mohammad Ahmed-1
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

Link to post
Share on other sites

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