jw_cad 外部変形 - (1091) clispで点マーカを描く -

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

 

clispで点マーカを描く

:clispで点マーカを描く
@echo off
set c=%*
if defined c call:set %c%
if exist %~dpn0.txt (
  for /f "tokens=*" %%a in (%~dpn0.txt) do call:set %%a
)
if not defined code set code=0
if not defined size set size=1
if defined c (
  echo %code% %size% > %~dpn0.txt
)

for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  more +%%n %0 | clisp -q > nul
)
goto:eof

REM #jww
REM #1%d 点位置を指示して下さい
REM #99#
REM #c マーカコード番号, 倍率
REM #e

:set
if not defined code set code=%1
if not defined size set size=%2
if "%1" == "/" set code=
if "%2" == "/" set size=
goto:eof

#!この次の行からプログラムを書いてください
;文字列 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
  )
))
;
;    ◎点マーカデータ
;pt %lg %lg %lg %lg %d     ( x   y  倍率  角度  マーカコード)
;   マーカコード
;    1:blancked arrow   2:blancked box   3:blancked dot    4:dimension origin
;    5:filled box       6:filled arrow   7:filled dot      8:integral symbol
;    9:Open Arrow      10:slash         11:unfilled arrow
;   -1:asterisk        -2:circle        -3:dot            -4:plus
;   -5:square          -6:triangle      -7:X
;   縮尺変更のとき、点マーカは文字サイズ変更と同様の扱いになる。
;
(setq hp '( (0 0)))
(setq hpn 1)
( ;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 "^hk" line) (setq hk (cadr a)))

    ;指示点データ
    (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))
        )
    )

  )
)
( ;準備計算
  progn
  (setq size (ext:getenv "size"))
  (if (equal size "") (setq size "1"))
  (setq d hk)
  (setq code (ext:getenv "code"))
  (if (equal code "") (setq code "0"))
)
( ;jwc_temp.txt へ 出力
  with-open-file (f "jwc_temp.txt" :direction :output)
  (progn
  (loop for i to (- (length hp) 1)
    do
    (if (> i 0) (
    progn
    (setq x (elt (elt hp i) 0))
    (setq y (elt (elt hp i) 1))
    (format f "pt ~a ~a ~a ~a ~a~%" x y size d code)
    ))
  )
  )
)