jw_cad 外部変形 - (1110) clispで罫線を引く -

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

 

clispで罫線を引く

:clispで罫線を引く
@echo off
set yp=8
set div=2
set sx=15
set sy=20
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  more +%%n %0 | clisp -q > nul
)
goto:eof

REM #jww
REM #hp
REM #zs
REM #e

#!この次の行からプログラムを書いてください
( ;準備計算
  progn
  (setq yp (read-from-string (ext:getenv "yp")))
  (setq div (read-from-string (ext:getenv "div")))
  (setq sx (read-from-string (ext:getenv "sx")))
  (setq sy (read-from-string (ext:getenv "sy")))
)
( ;jwc_temp.txt へ 出力
  with-open-file (g "jwc_temp.bak" :direction :output)
( ;jwc_temp.txt から 入力
  with-open-file (f "jwc_temp.txt" :direction :input)
  (loop for line = (read-line f nil) while line do
    (setq a (regexp:regexp-split "\\s\\+" line))
    (if (regexp:match "^hzs" line)
        (progn
          (setq w (read-from-string (nth 1 a)))
          (setq h (read-from-string (nth 2 a)))
          (setq n (/ (- h (* sy 2)) yp))
          (setq x0 sx)
          (setq x1 (+ x0 (- (/ w div) sx)))
          (write-line "bz" g)
          (write-line "lc9" g)
          (write-line "lt9" g)
          (loop for i from 0 to (- n 1)
           do
            (setq y (+ (* yp i) sy))
            (format g "~{ ~f~}~%" (list x0 y x1 y))
          )
        )
    )
  )
)
)
(delete-file "jwc_temp.txt")
(rename-file "jwc_temp.bak" "jwc_temp.txt")