jw_cad 外部変形 - (872) pythonでスケールを取得する(hs) -

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

 

pythonでスケールを取得する(hs)

:pythonでスケールを取得する(hs)
@echo off
if not exist %~dpn0.py (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.py
  )
)
copy jwc_temp.txt myfiles > nul
python %~dpn0.py > jwc_temp.txt
goto:eof

REM #jww
REM #e

#!この次の行からプログラムを書いてください
# coding: shift_jis
import sys,re

hs = {}
lg = ""

try :
  f = open("myfiles", "r")
  for a in f:
    F = a.split()
    if re.compile("^hs").search(a):
      i = 0
      for x in F[1:]:
        hs[str(hex(i)[2:])] = float(x)
        i += 1
    if re.compile("^lg").search(a):
      plg = a[2:3]
      if lg == "":
        lg = plg
  f.close()
except :
  sys.exit()

print("h#S=1/%s" % hs[lg])