jw_cad 外部変形 - (497) clispで点を打つ -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

clispで(線の両端に)点を打つ

:clispで点を打つ
@echo off
if not exist %~dpn0.lisp (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.lisp
  )
)
clisp %~dpn0.lisp
goto:eof

REM #jww
REM #1ln 基準線を指示してください
REM #e

#!この次の行からプログラムを書いてください
(defmacro while (test &body body)
  `(do ()
   ( (not ,test) )
   ,@body)
)
(with-open-file (f "jwc_temp.txt" :direction :input)
  (while (setq line (read-line f nil))
    (setq a (regexp:regexp-split "\\s\\+" line))
    (if (regexp:match "^ " line) (setq ln1 a) nil)
  )
  (close f)
)
(setq x1 (read-from-string (nth 1 ln1)))
(setq y1 (read-from-string (nth 2 ln1)))
(setq x2 (read-from-string (nth 3 ln1)))
(setq y2 (read-from-string (nth 4 ln1)))
(with-open-file (f "jwc_temp.txt" :direction :output)
  (write-line (format nil "pt ~A ~A" x1 y1) f)
  (write-line (format nil "pt ~A ~A" x2 y2) f)
  (close f)
)