#| Ersteller/Creator: Patrick Weber Datum/Date: 2011-06-10 Diskussion/Thread: http://ww3.cad.de/foren/ubb/Forum92/HTML/000703.shtml v1.2 (2012-08-02) |# (in-package :custom) (use-package :OLI) (sd-defdialog 'xy-csv-import-dialog :dialog-title "XY-Koordinaten auf AE" :toolbox-button t :variables '( (InFile :value-type :filename :title "Quelldatei" :direction :input :prompt-text "Quelldatei angeben" :filename-incl-path t :initialPattern "*.*" ) ("-") (Delimiter :value-type :string :initial-value " " :proposals '(" " "," ";" "_" "tabulator") :title "Separatorzeichen" :prompt-text "Separatorzeichen wÌhlen" ) ("-") (CloseContour :value-type :boolean :initial-value t :title "Kontur schlieÞen" ) ) :local-functions '( (xy-csv-import () (let ((coords '())) (with-open-file (Ascii_file (first InFile) :direction :input :if-does-not-exist nil) (loop while (setq Line_ (read-line Ascii_file nil)) do (let ((xy_ (sd-string-split Line_ (if (string-equal Delimiter "tabulator") #\Tab Delimiter)))) (setf point (make-gpnt2d :x (read-from-string (nth 0 xy_)) :y (read-from-string (nth 1 xy_)))) (push point coords) ) ) ) (when (> (length coords) 1) (setf coords (reverse coords)) (sd-call-cmds (geometry_mode :real)) (loop for i from 0 to (- (length coords) 2) do (sd-call-cmds (line :two_points (nth i coords) (nth (+ i 1) coords))) ; (display (format nil "line :two_points ~A ~A" (nth i coords) (nth (+ i 1) coords))) ) (when (and CloseContour (> (length coords) 2)) (sd-call-cmds (line :two_points (first coords) (nth (- (length coords) 1) coords)))) ; (display (format nil "line :two_points ~A ~A" (first coords) (nth (- (length coords) 1) coords))) ) ) ) ) :ok-action '(let () (xy-csv-import) ) )