いつもお世話になっております。
配管の側面(両側中心振分オフセット)をLispで作成しております。
SGPと塩ビでは口径の呼びが違うため、それぞれ違う引数を使いたいのですが(SGPはPsize 塩ビはVPsize)Psizeはできても塩ビ用にVPsizeに設定することができません。
どのようにすればいいのかわからず困っております。
ご教授いただけないでしょうか?
使用CAD:AutoCAD2025
SGP用Lisp
(defun c:get_my_SGPsize ()
(setq LUP (getvar "LUPREC"));長さ小数点取得
(setvar "LUPREC" 1);長さ小数点以下0桁に設定 ダイナミック入力時の表示
(initget "6 8 10 15 20 25 32 40 50 65 80 100 125 150 200 250 300 350 400 450 500")
(setq Psize (getkword (strcat "\nSGP配管口径を選択または入力 繰り返しは【ENTERまたは右クリック】 <" *last-Psize* ">:[6/8/10/15/20/25/32/40/50/65/80/100/125/150/200/250/300/350/450/500] ")))
(if (not Psize)
(setq Psize *last-Psize*)
)
(setq *last-Psize* Psize)
(command "offsetdist" Psize)
(setq dist (getvar "offsetdist"))
(setq dist (rtos dist));実数を文字列に変換
(cond ((= dist "6")(setq dist "10.5"))
((= dist "8")(setq dist "13.8"))
((= dist "10")(setq dist "17.3"))
((= dist "15")(setq dist "21.7"))
((= dist "20")(setq dist "27.2"))
((= dist "25")(setq dist "34"))
((= dist "32")(setq dist "42.7"))
((= dist "40")(setq dist "48.6"))
((= dist "50")(setq dist "60.5"))
((= dist "65")(setq dist "76.3"))
((= dist "80")(setq dist "89.1"))
((= dist "100")(setq dist "114.3"))
((= dist "125")(setq dist "139.8"))
((= dist "150")(setq dist "165.2"))
((= dist "200")(setq dist "216.3"))
((= dist "250")(setq dist "267.4"))
((= dist "300")(setq dist "318.5"))
((= dist "350")(setq dist "355.6"))
((= dist "400")(setq dist "406.4"))
((= dist "450")(setq dist "457.2"))
((= dist "500")(setq dist "508"))
((= dist "")(setq dist ""))
(t)
)
(setq dist (atof dist));文字列を実数に変換
(setq dist (/ dist 2 ))
(command "offsetdist" dist)
(if (and
(setq PT1 (getpoint "1点目を指示\n")) ;現在のUCSで表された3D点が返る;
(setq PT2 (getpoint PT1 "2点目を指示または数値入力\n")) ;現在のUCSで表された3D点が返る;
(setq ang (* (/ (angle PT1 PT2) pi) 180)) ;角度をラジアンから度数に変換
)
(progn;複数の()を使うための関数
(command "LINE" PT1 PT2 "" "select" "L" "" "offset" dist "@" "@" "" "erase" "P" "" )
(command "._offset" (* 2 dist) (entlast) "@" "" )
(command "offsetdist" (* 2 dist))
);prognの閉じカッコ
);if関数の終わりのカッコ
(setvar "LUPREC" LUP)
);defun
塩ビ用Lisp
(defun c:get_my_VPsize ()
(setq LUP (getvar "LUPREC"));長さ小数点取得
(setvar "LUPREC" 1);長さ小数点以下0桁に設定 ダイナミック入力時の表示
(initget "13 16 20 25 30 40 50 65 75 100 125 150")
(setq VPsize (getkword (strcat "\n塩ビ配管口径を選択または入力 繰り返しは【ENTERまたは右クリック】<" *last-VPsize* ">:[13/16/20/25/30/40/50/65/75/100/125/150] ")))
(if (not VPsize)
(setq VPsize *last-VPsize*)
)
(setq *last-VPsize* VPsize)
(command "offsetdist" VPsize)
(setq dist (getvar "offsetdist"))
(setq dist (rtos dist));実数を文字列に変換
(cond ((= dist "13")(setq dist "18"))
((= dist "16")(setq dist "22"))
((= dist "20")(setq dist "26"))
((= dist "25")(setq dist "32"))
((= dist "30")(setq dist "38"))
((= dist "40")(setq dist "48"))
((= dist "50")(setq dist "60"))
((= dist "65")(setq dist "76"))
((= dist "75")(setq dist "89"))
((= dist "100")(setq dist "114"))
((= dist "125")(setq dist "140"))
((= dist "150")(setq dist "165"))
((= dist "")(setq dist ""))
(t)
)
(setq dist (atof dist));文字列を実数に変換
(setq dist (/ dist 2 ))
(command "offsetdist" dist)
(if (and
(setq PT1 (getpoint "1点目を指示\n")) ;現在のUCSで表された3D点が返る;
(setq PT2 (getpoint PT1 "2点目を指示または数値入力\n")) ;現在のUCSで表された3D点が返る;
(setq ang (* (/ (angle PT1 PT2) pi) 180)) ;角度をラジアンから度数に変換
)
(progn;複数の()を使うための関数
(command "LINE" PT1 PT2 "" "select" "L" "" "offset" dist "@" "@" "" "erase" "P" "" )
(command "._offset" (* 2 dist) (entlast) "@" "" )
(command "offsetdist" (* 2 dist))
);prognの閉じカッコ
);if関数の終わりのカッコ
(setvar "LUPREC" LUP)
);defun
塩ビを実行した時のコマンドの流れです。
._UNDO 現在の設定: 自動 = オン, コントロール = すべて, 合成 = はい, 画層 = はい
取り消す操作の数を入力 または [自動(A)/コントロール(C)/開始(BE)/終了(E)/マーク(M)/後退(B)] <1>: _E ._UNDO 現在の設定: 自動 = オン, コントロール = すべて, 合成 = はい, 画層 = はい
取り消す操作の数を入力 または [自動(A)/コントロール(C)/開始(BE)/終了(E)/マーク(M)/後退(B)] <1>: 1 APPLOAD ***MyERR***: 引数のタイプが間違っています: stringp nil
SGP配管と塩ビ配管で引数を変えたい
- mappy
- 2025/07/16 (Wed) 12:56:04