TOP PAGE > 記事閲覧
SIMAファイル読み込み〜ARES展開プロット
投稿日 : 2019/08/19(Mon) 10:21
投稿者 だい
参照先
↓こちらのスレッドを参考にして、SIMAファイルを読み込んでプロットするLISPを作成しました。ありがとうございます。

LISPを使ったCSVファイルへの読み書き
http://r-support.org/bbs/patio.cgi?read=45&ukey=0


↓こちらを SIMA_PLOT.lspとして下さい。

(defun C:SIMA_PLOT ( / fpt SPS set_val set_lst mojidaka_str hankei_str mt_val mmt_val dcl_id ddiag)

(setq fpt (strcat (vl-string-right-trim "lsp" (findfile "SIMA_PLOT.lsp")) "txt"));ダイアログ項目の保存用テキストファイルのフルパス
(setq SPS (open fpt "r"))
(if (= SPS nil)
(setq set_lst (list "0.3" "0.05" "1" "0"))
(progn
(setq set_val (read-line SPS))
(setq set_lst (list set_val))
(while (/= set_val nil)
(setq set_val (read-line SPS))
(setq set_lst (append set_lst (list set_val)))
);while
(close SPS)
);progn
);if

(setq mojidaka_str (nth 0 set_lst))
(setq hankei_str (nth 1 set_lst))
(setq mt_val (nth 2 set_lst))
(setq mmt_val (nth 3 set_lst))

(setq dcl_id (load_dialog "SIMA_PLOT.dcl"))
(new_dialog "SIMA_PLOT" dcl_id "" '(1700 150))

(set_tile "mojidaka" mojidaka_str)
(set_tile "hankei" hankei_str)
(set_tile "mt" mt_val)
(set_tile "mmt" mmt_val)

(action_tile "accept" "(SaveTileVal)(done_dialog 1)");OKボタンの場合
(action_tile "cancel" "(done_dialog 0)");キャンセルボタンの場合

(defun SaveTileVal ()
(setq mojidaka_str (get_tile "mojidaka"))
(setq hankei_str (get_tile "hankei"))
(setq mt_val (atoi(get_tile "mt")))
(setq mmt_val(atoi(get_tile "mmt")))

(setq SPS (open fpt "w"))
(write-line mojidaka_str SPS)
(write-line hankei_str SPS)
(write-line (itoa mt_val) SPS)
(write-line (itoa mmt_val) SPS)
(close SPS)
);SaveTileVal

(setq ddiag (start_dialog))
(unload_dialog dcl_id)

(if (= (getvar "DIASTAT") 1)(sentaku mt_val mojidaka_str hankei_str));最後に使用したダイアログ ボックスの終了方法が"OK"で閉じたら
(princ)
);SIMA_PLOT

(defun sentaku ( mt_val mojidaka_str hankei_str / n filePath fr txt ci tenmei X Y Xmojisuu Xichi Xketa Ymojisuu Yichi Yketa point_data )
(setvar "CMDECHO" 0);command 関数を実行中にプロンプトとユーザ入力をエコーバック表示しない
(setq n 0)
(setq filePath (getfiled "SIMAファイルを選択" "" "sim" 16))
(setq fr (open filePath "r"));ファイルを開く
(if (/= fr nil)
(while
(setq txt (read-line fr));1行ずつ読み込む
(if (= (substr txt 1 3) "A01")
(progn
(setq ci (vl-string-position (ascii ",") txt))
(setq txt (substr txt 5))
(setq ci (vl-string-position (ascii ",") txt))
(setq txt (substr txt (+ ci 2)))
(setq ci (vl-string-position (ascii ",") txt))
(setq tenmei (substr txt 1 ci))
(setq txt (substr txt (+ ci 2)))
(setq ci (vl-string-position (ascii ",") txt))
(setq X (substr txt 1 ci))
(setq txt (substr txt (+ ci 2)))
(setq ci (vl-string-position (ascii ",") txt))
(setq Y (substr txt 1 ci))

(if (= mt_val 0)
(progn
(setq Xmojisuu (strlen X))
(setq Xichi (vl-string-position (ascii ".") X 0))
(if (or (= Xichi nil) (< (- Xmojisuu Xichi 1) 4))
(setq Xketa 0)
(setq Xketa (- Xmojisuu Xichi 4))
);if
(setq Ymojisuu (strlen Y))
(setq Yichi (vl-string-position (ascii ".") Y 0))
(if (or (= Yichi nil) (< (- Ymojisuu Yichi 1) 4))
(setq Yketa 0)
(setq Yketa (- Ymojisuu Yichi 4))
);if
(setq X (rtos (* (distof X 2) 1000) 2 Xketa))
(setq Y (rtos (* (distof Y 2) 1000) 2 Yketa))
);progn
);if

(setq point_data (strcat Y "," X))
(setq n (+ n 1))
(command "_point" point_data)
(if (= n 1)
(command "_select" "_l" "");後でグループ化するため(1点目は前回の選択セットを取得しない)
(command "_select" "_l" "_p" "");後でグループ化するため
);if
(command "_circle" point_data hankei_str)
(command "_select" "_l" "_p" "");後でグループ化するため
(command "_text" point_data mojidaka_str "0" tenmei)
(command "_select" "_l" "_p" "");後でグループ化するため
);progn
);if
);while
(prompt "\n <<エラー>> ファイルが開けません。")
);if
(close fr);ファイルを閉じる

(command "-group" "" "*" "" "p" "");プロットした物を全てグループ化する
(if (= mt_val 0)
(command "_zoom" "c" point_data "10000")
(command "_zoom" "c" point_data "10")
);if
(setvar "CMDECHO" 1)
(princ)
);sentaku
記事編集 編集
Re: SIMAファイル読み込み〜ARES展開プロット
投稿日 : 2019/08/19(Mon) 10:24
投稿者 だい
参照先
ダイアログを使うので、こちらを SIMA_PLOT.dcl として保存して下さい。

/* SIMA_PLOT.dcl - dcl file for SIMA_PLOT.lsp program */

SIMA_PLOT :dialog
{
label = "SIMA 座標プロット";
:column
{
:column
{
:edit_box
{
label = " 文字高さ ";
key = "mojidaka";
width = 5;
}

:edit_box
{
label = " 円の半径 ";
key = "hankei";
width = 5;
}

}

:row
{
:text
{
label = "作図単位";
key = "";
width = 8;
}

:radio_button
{
label = "m";
key = "mt";
width = 2;
}

:radio_button
{
label = "mm";
key = "mmt";
width = 2;
}
}
}

/* OK or CANCEL */
spacer;
//ok_cancel;
:row
{
:button
{
label = "SIMAファイル選択";
is_default = true;
key = "accept";
width = 14;
fixed_width = true;
}

//:spacer { width = 1; }

:button
{
label = "終了";
is_cancel = true;
key = "cancel";
width = 4;
fixed_width = true;
}
}
}
記事編集 編集
ページの上に移動
件名 スレッドをトップへソート
名前
メールアドレス
URL
暗証キー
画像認証 (右画像の数字を入力) 投稿キー
コメント


- WEB PATIO -