外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
clispで指示円を確認する(ci)
:clispで指示円を確認する(ci)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
copy jwc_temp.txt myfiles > nul
more +%%n %0 | clisp -q > nul
)
goto:eof
REM #jww
REM #1%dci 円を指示してください
REM #99#
REM #bz
REM #e
#!この次の行からプログラムを書いてください
;ユーザ定義関数
;文字列 str の old に一致する部分を new で置き換える
(defun gsub (old new str)
(let (s e)
(if (search old str)
(progn
(setq s (search old str))
(setq e (+ s (length old)))
(setq str (concatenate 'string (subseq str 0 s) new (subseq str e)))
(gsub old new str)
)
str
)
))
( ;文字列 "x" を 数値 xd0 (倍精度 double-float) に変換
defun to_f (x)
(if (equal x nil) (setq x "0"))
(if (listp x)
(mapcar #'to_f x)
(progn
(if (typep x 'double-float)
x
(progn
(if (stringp x) nil (setq x (write-to-string x)))
(if (search "e" x)
(progn
(setq s (search "e" x))
(read-from-string
(concatenate 'string (subseq x 0 s) "d" (subseq x (+ 1 s) (length x)))
)
) ;progn (search "e" x)
(if (search "d" x)
x
(read-from-string
(concatenate 'string x "d0")
)
)
)
) ;progn (typep x 'double-float)
)
) ;progn (listp x)
)
)
( ;文字列 "x" を 整数に変換
defun to_i (x)
(if (numberp x)
(* (signum x) (floor (abs x)))
(progn
(if (equal x nil) (setq x "0"))
(if (listp x)
(mapcar #'to_i x)
(progn
(if (stringp x) nil (setq x (write-to-string x)))
(parse-integer x)
)
)
)
)
)
(defun hp (i &optional j)
(if (equal j "x") (setq j 0))
(if (equal j "y") (setq j 1))
(if j (if (> (abs j) 1) (setq j nil)))
(if j (elt (elt hp i) j) (elt hp i))
)
(defun ci (i &optional j)
(if (equal j "x") (setq j 0))
(if (equal j "y") (setq j 1))
(if (equal j "r") (setq j 2))
(if (equal j "p1") (setq j 3))
(if (equal j "p2") (setq j 4))
(if (equal j "w") (setq j 5))
(if (equal j "d") (setq j 6))
(if (equal j "c")
(subseq (ci i) 0 2)
(progn
(if j (if (> (abs j) 6) (setq j nil)))
(if j (elt (elt ci i) j) (elt ci i))
)
)
)
;本文
(setq hp '( (0 0)))
(setq hpn 0)
(setq ci '( (0 0 0 0 0 1 0)))
(setq cin 0)
( ;jwc_temp.txt へ 出力
with-open-file (g "jwc_temp.txt" :direction :output)
( ;myfiles から 入力
with-open-file (f "myfiles" :direction :input)
(loop for line = (read-line f nil) while line do
(setq a (regexp:regexp-split " \\+" line))
(if (regexp:match "^hq" line)
(write-line "bz" g)
)
;指示点データ
(if (regexp:match "^hp[1-9][0-9]\\?\\(ln\\|ci\\|ch\\)\\?-\\?" line)
(progn
(setq hpn (gsub "hp" "" (car a)))
(setq hpn (gsub "ln" "" hpn))
(setq hpn (gsub "ci" "" hpn))
(setq hpn (gsub "ch" "" hpn))
(setq hpn (gsub "#" "" hpn))
(setq hpn (parse-integer (gsub "-" "" hpn)))
(if (>= (- hpn (length hp)) 0)
(loop for i to (- hpn (length hp)) do
(setq hp (append hp '( (0 0))))
)
)
(setf (elt hp hpn) (cdr a))
)
)
;指示円データ
(if (regexp:match "^hhp[1-9][0-9]\\?ci" line)
(progn
(setq cin (gsub "hhp" "" (nth 0 a)))
(setq cin (gsub "ci" "" cin))
(setq cin (parse-integer cin))
)
)
(if (regexp:match "^ci" line)
(progn
(if (= cin 0) (setq cin (length ci)))
(if (>= (- cin (length ci)) 0)
(loop for i to (- cin (length ci)) do
(setq ci (append ci '( (0 0 0 0 0 1 0))))
)
)
(setf (elt ci cin) (cdr a))
;指示点 (x y) に 半径 1mm の円を描く
(setq x (nth 0 (hp cin)))
(setq y (nth 1 (hp cin)))
(format g "ci ~f ~f ~f~%" x y 1)
;指示円の中心に点を打つ
(setq x (to_f (nth 0 (ci cin))))
(setq y (to_f (nth 1 (ci cin))))
(format g "pt ~f ~f~%" x y)
)
)
)
)
)
○jw_cad 外部変形用ライブラリ jw.lisp の使用例
:clispで指示円を確認する(ci : -i jw.lisp)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
more +%%n %0 | clisp -q -i \jww\Lite\pro\jw > nul
)
goto:eof
REM #jww
REM #1%dci 円を指示してください
REM #99#
REM #bz
REM #e
#!この次の行からプログラムを書いてください
(jw
(bz)
(loop for i from 1 to cin
do
;指示点 (x y) に 半径 1mm の円を描く
(circle (hp i) 1)
;指示円の中心に点を打つ
(setq x (to_f (nth 0 (ci i))))
(setq y (to_f (nth 1 (ci i))))
(point x y)
)
)