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

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

 

pythonで点マーカを描く

:pythonで点マーカを描く
@echo off
if not exist %~dpn0.py (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.py
  )
)
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
)
copy jwc_temp.txt myfiles > nul
python %~dpn0.py > jwc_temp.txt
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

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

code = int(os.environ['code'])
size = float(os.environ['size'])
if size == 0 :
  size = 1

try :
  f = open("myfiles", "r")
  for line in f:
    F = line.split()
    if re.compile("^hk").search(line): hk = float(F[1])
    if re.compile("^hp").search(line):
      print("pt %s %s %s %s %s" % (F[1], F[2], size, hk, code))
  f.close()
except :
  sys.exit()