Assuming your "source" is a CDF file (a text file in which the X-, Y- and Z-value of each coordinate are separted by a comma) or a SDF file (a text file in which the X-, Y- and Z-value of each coordinate are separted by one or more space(s) ) you can try the attached LISP. (Don't worry about the german comments, it works in all other language versions of AutoCAD too).
;;; Eine CDF-Datei (Comma Delimited Format) enthält eine Koordinate je Zeile,
;;; wobei die X-, Y- und Z-Werte durch je ein Komma getrennt sind:
;;;
;;; 2.333,4.23,8.0
;;; -4.33,0.0,6.3
;;; 0.322,5.32,0.0
;;; ...
;;;
;;; In der CDF-Datei dürfen keine Leerzeichen und keine Leerzeilen enthalten sein.
;;;
;;;
;;;
;;; Eine SDF-Datei (Space Delimited Format) enthält eine Koordinate je Zeile,
;;; wobei die X-, Y- und Z-Werte durch ein oder mehrere Leerzeichen getrennt sind:
;;;
;;; 2.333 4.23 8.0
;;; -4.33 0.0 6.3
;;; 0.322 5.32 0.0
;;; ...
;;;
;;; Es sind wahlweise 2D-oder 3D-Koordinaten zulässig.
;;;
;;; Als Dezimaltrennzeichen ist in jedem Fall der Punkt zu verwenden!
(defun C:ASCPOINT (/ f bm hi format input read-point line plist ss)
(cond ((eq "" (setq f (getfiled "" "" "" 0))))
((not (setq f (open f "r")))
(princ "\nKann Datei nicht öffnen.")
)
(t
(initget "Space Comma")
(setq format
(cond ((getkword "\nComma/Space delimited <Comma>: "))
(t "Comma")
)
)
(initget "Copies Lines Nodes 3dpoly Pline Spline")
(setq input
(cdr
(assoc
(cond
((getkword
"\nErzeuge Copies/Lines/Nodes/3dpoly/Spline/<Pline>: "
)
)
(t "Pline")
)
'(("Lines" . "_.line")
("Copies" . "_.copy")
("Nodes" . "_.point")
("3dpoly" . "_.3dpoly")
("Pline" . "_.pline")
("Spline" . "_.spline")
)
)
)
)
(setq read-point
(cond ((eq format "Comma") cdf)
(t sdf)
)
)
(setvar "cmdecho" 0)
(command "_.undo" "_g")
(setq hi (getvar "highlight"))
(princ "\nLese Daten...")
(while (setq line (read-line f))
(cond ((setq line (strtrim line))
(setq line (read-point line))
(setq plist (append plist
(cond ((eq input "_.pline")
(list (noz line))
)
(t (list line))
)
)
)
)
)
)
(close f)
(cond ((eq input "_.point")
(setvar "highlight" 0)
(command "_.point"
"0,0,0"
"_.copy"
(setq ss (entlast))
""
"_m"
"0,0,0"
)
(apply 'command plist)
(command)
(entdel ss)
)
((eq input "_.copy")
(princ "\nWähle zu kopierende Objekte,")
(while (not (setq ss (ssget)))
(princ "\nKeine Objekte gewählt,")
(princ " wähle zu kopierende Objekte,")
)
(setvar "highlight" 0)
(command "_.copy" ss "" "_m" "0,0,0")
(apply 'command plist)
(command)
)
((eq input "_.spline")
(command input)
(apply 'command plist)
(command "")
(command "")
(command "")
)
(t
(command input)
(apply 'command plist)
(command)
)
)
(command "_.undo" "_e")
(setvar "highlight" hi)
)
)
(princ)
)
(defun cdf (l)
(command "_.setvar" "lastpoint" l)
(getvar "lastpoint")
)
(defun sdf (l)
(read (strcat "(" l ")"))
)
(defun noz (p)
(list (car p) (cadr p))
)
(defun strtrim (s)
(while (eq " " (substr s 1 1))
(setq s (substr s 2))
)
(while (eq " " (substr s (strlen s)))
(setq s (substr s 1 (1- (strlen s))))
)
(cond ((eq s "") nil)
(t s)
)
)
(princ "\nC:ASCPOINT geladen. Starte mit ASCPOINT. ")
(princ)
Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
