jw_cad 外部変形 - (1063) tclshで指示点を確認する(hp) -

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

 

tclshで指示点を確認する(hp)

:tclshで指示点を確認する(hp)
@echo off
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 #1-%d 点を指示してください
REM #99#
REM #zs
REM #e

#!この次の行からプログラムを書いてください
set tcl_precision 16; #文字列を数値演算するとき有効桁数 16 (デフォルト 12)
set lg ""
set hpn 0

set f [open myfiles]
foreach 0 [split [read $f] \n] {
  switch -regexp -matchvar n -- $0 {
    ^hq {
      continue
    }
    ^hs {
      for {set i 0} {$i <= 15} {incr i} {
        set hs([format "%x" $i]) [lindex $0 [expr $i + 1]]
      }
    }
    ^hzs {
      set w [lindex $0 1]
      set h [lindex $0 2]
    }
    {^hp(\d+)} {
      set hpn [lindex $n 1]
      set hp($hpn) [lrange $0 1 2]
    }
    ^lg[0-9a-f] {
      set plg [string index $0 2]
      if {$lg == ""} {set lg $plg}
    }
  }
}
close $f

set sc $hs($lg)
set w [expr $w * $sc]
set h [expr $h * $sc]
puts "[expr -$w / 2.0] 0 [expr $w / 2.0] 0"
puts "0 [expr -$h / 2.0] 0 [expr $h / 2.0]"
puts "ch 0 0 1 0 \"\[0, 0\]"
for {set i 1} {$i <= $hpn} {incr i} {
  lassign $hp($i) x y
  puts "pt $x $y"
  puts [format "ch $x $y 1 0 \"\[%s\]" [join $hp($i) ","]]
}