[.net] How to import text from file with .lis

[.net] How to import text from file with .lis

Anonymous
Not applicable
1,088 Views
3 Replies
Message 1 of 4

[.net] How to import text from file with .lis

Anonymous
Not applicable
Hi everyone, Is there any lisp programme that can import serial of text (depth) into autocad and place at their coordinate? (for Bathymetric Survey drawing) coordinates Depth 15695.1296, 31328.9000 14.5 15699.7000, 31328.9704 14.5 15701.5200, 31328.8704 14.4 15703.4096, 31328.8104 14.4 15707.2896, 31328.8504 14.3 15710.0496, 31328.9704 14.2 15691.0664, 31329.2360 13.7 15705.2496, 31329.2400 14.3 Thanks & Best Regards, TS8483
0 Likes
1,089 Views
3 Replies
Replies (3)
Message 2 of 4

john.uhden
Mentor
Mentor

I have an old PTIMPORT.lsp which reads a delimited TXT file (or CSV) and inserts a POINT block at each point.

The POINT block contains an AutoCAD point at its insertion and attributes for Pt#, Elev., and Desc. so the file format is PNEZD, short for

Point#, North, East, Elev., Description.

 

We can fix it up for whatever format you want.

John F. Uhden

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi john.uhden ,

 

Can your lisp file read from a text file which consist of the following data , ie 14.3 , 14.5, 14.2.....and place the value to the respective X, Y position?

 

    X            Y                DEPTH

15693.2   31328.7          14.3

15695.1   31328.9          14.5

15699.7   31328.8          14.2

0 Likes
Message 4 of 4

pbejse
Mentor
Mentor

@Anonymous wrote:

 


Can your lisp file read from a text file which consist of the following data , ie 14.3 , 14.5, 14.2.....and place the value to the respective X, Y position?

 

 


Yes a lisp can read the data from a text file.

 

A middle center justified TEXT entity are placed on the X,Y position with this demo, text (.txt) file is TAB delimited

 

(Defun c:demo (/ _delimeter lst text_file openfile p_ StringToReal string)
  ;;			pBe March 2018			;;
  (defun _delimeter	(str md / p lst)
    (while (setq p (vl-string-position md str))
	 (setq lst (Cons (substr str 1 p) lst))
	 (setq str (substr str (+ p 2)))
    ) ;_ end of while
    (reverse (cons str lst))
  ) ;_ end of defun

  (if (setq lst	  nil
		  text_file (getfiled "Choose CSV file" "" "TXT;CSV" 16)
	 ) ;_ end of setq
    (progn
	 (setq openfile (open text_file "R"))
	 (while (setq string (read-line openfile))
	   (if (apply 'and
			    (setq	StringToReal
					 (mapcar 'distof (_delimeter string 9))
			    ) ;_ end of setq
		  ) ;_ end of apply
		(setq lst (cons StringToReal lst))
	   ) ;_ end of if
	 ) ;_ end of while
	 (close openfile)
	 (foreach	itm lst
	   (entmakex
		(list
		  (cons 0 "TEXT")
		  (cons 10 (Setq p_ (list (Car itm) (cadr itm))))
		  (cons 11 p_)
		  '(72 . 4)
		  '(73 . 3)
		  (cons 40 (getvar 'textsize))
		  (cons 1
			   (rtos (last itm) 2 1)
		  ) ;_ end of cons
		) ;_ end of list
	   ) ;_ end of entmakex
	 ) ;_ end of foreach
    ) ;_ end of progn
  ) ;_ end of if
  (princ)
) ;_ end of Defun

HTH

 

 

0 Likes