jw_cad 外部変形 - (1050) tclshで罫線を引く -

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

 

tclshで罫線を引く

:tclshで罫線を引く
@echo off
set sx=15
set sy=20
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | tclsh - > jwc_temp.txt
)
goto:eof

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

#!この次の行からプログラムを書いてください
set tcl_precision 16; #文字列を数値演算するとき有効桁数 16 (デフォルト 12)
set sx $env(sx)
set sy $env(sy)
set yp 8;  # 行間隔 mm
set div 2; # 用紙を横に2分割

set f [open myfiles]
foreach 0 [split [read $f] \n] {
  switch -regexp -- $0 {
    ^hzs {
      set w [lindex $0 1]
      set h [lindex $0 2]
      set n [expr int( ($h - $sy * 2) / $yp)]
      set x0 $sx
      set x1 [expr $x0 + ($w / $div - $sx)]
      puts "bz"
      puts "lc9"
      puts "lt9"
      for {set i 0} {$i < $n} {incr i} {
        set y [expr $yp * $i + $sy]
        puts "$x0 $y $x1 $y"
      }
    }
  }
}
close $f