TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Ron Heigh on September 09, 2005, 10:45:59 AM
-
Is there any way to create a drawing full of points based a txt file with the x,y,z format?
I have hundreds from our surveyor, and need to recreate them all in AutoCAD.
The format is as follows:
0,0,2540.6858
2.75733,0.12301,2541.06505
10.63198,0.08052,2541.87804
19.06206,0.0576,2542.86645
-
I got it.
Thanks guys.
-
Darn, too slow again.....
Well, here's a solution anyway.....
(defun c:import_pts (/ file ff ln pt_lst)
;;;str2list by John Uhden, as posted to the adesk customization newsgroup
(defun Str2List (str pat / i j n lst)
(cond
((/= (type str) (type pat) 'STR))
((= str pat) '(""))
(T
(setq i 0
n (strlen pat)
)
(while (setq j (vl-string-search pat str i))
(setq lst (cons (substr str (1+ i) (- j i)) lst)
i (+ j n)
)
)
(reverse (cons (substr str (1+ i)) lst))
)
)
)
;;*********
(cond ((not (setq file (getfiled "Select CSV File" "" "" 0)))
(princ "\nMust have a file to use! Try again....")
)
;; cond1
((not (and (setq ff (open file "r"))
(setq ln (read-line ff))
(vl-string-search "," ln 0)
)
)
(princ "\nNot a valid CSV file, try again.....")
)
;;cond2
((while ln
(setq pt_lst (str2list ln ","))
(entmake (list '(0 . "POINT")
(cons 10
(list (atof (car pt_lst))
(atof (cadr pt_lst))
(atof (cadr pt_lst))
)
)
)
)
(setq ln (read-line ff))
)
;;while
(close ff)
)
;;cond3
)
(princ)
)
-
I got it.
Thanks guys.
I gues you did it
put point at command line
before you select all your point at the txt file , do a copy
and paste it at the command line when acad promt you to place the point
-
I hope it had point numbers and descriptions included ... if not that will be messy
-
Is there any way to create a drawing full of points based a txt file with the x,y,z format?
I have hundreds from our surveyor, and need to recreate them all in AutoCAD.
The format is as follows:
0,0,2540.6858
2.75733,0.12301,2541.06505
10.63198,0.08052,2541.87804
19.06206,0.0576,2542.86645
I just thought I would jump in here and share a little code I use for CSV files.
Just FYI
Peter Jamtgaard
; Written By: Peter Jamtgaard P.E. copr 2004
; Import a CSV File to a list of Sublists
(defun csvFiletoList (strFilename strChar / lstOfSublists strText z)
(setq z (open strFilename "r"))
(while (setq strText (read-line z))
(setq lstOfSublists (cons (CSVStringToList strText strChar) lstOfSublists))
)
(close z)
(reverse lstOfSublists)
)
; Parsing a textstring to a list.
; Written By: Peter Jamtgaard P.E. copr 2004
(defun CSVStringToList (strText strChar / intPosition lstStrings)
(while (setq intPosition (vl-string-search strChar strText 0))
(setq lstStrings (cons (substr strText 1 intPosition) lstStrings)
strText (substr strText (+ intPosition 1 (strlen strChar)))
)
)
(reverse (cons strText lstStrings))
)