<<<**** 簡易多功能dcl創建+參數式轉lisp檔 *****>>>
本帖最后由 lee50310 于 2023-6-26 06:23 编辑**** 簡易多功能dcl創建+參數式轉lisp檔*****
簡單的說你只要你熟悉規則 ,自行撰寫 dlst列表 將其帶入 兩個函數並設好參數(a.起始對話框函數 與 b.結束對話框函數)
可用此程式 快速建立dcl檔 並利用內部參數0,1,2,3順便轉檔 要轉換成何種格式可自行決定填入的參數
並用轉出的lisp檔繼續寫作 不必在依附 great-dcl.fas 此程式
(ps: dlst列表內 不可加// 註解符號 ,可轉成dcl檔後再自行加入)
此DCL創建 共分為 3步驟
(1)載入DCL轉換函數 great-dcl.fas
(2)需自行撰寫dlst列表
(3)a.輸入 起始對話框函數並設置參數 ,b.輸入 結束對話框函數並設置參數
內附6個 程式範例檔 裡面有撰寫 dlst列表 的格試範例
可供作參考 (執行指令分別為 tt1,tt2,tt3,tt4,tt5,tt6)及使用說明 ...等
如何編寫 dlst列表 及DCL啟動函數之參數 規則寫在說明內 使用前請詳看 說明
程式檔案路徑
簡體版=>設置 D:\\great_dcl_chs\\
繁體版=>設置:D:\\great_dcl_cht\\
若所存放的檔案及路徑與此不同需修改程式內此值
本帖最后由 lee50310 于 2023-6-25 09:59 编辑
將他帶入轉換程式並寫成執行檔如下
(defun c:tt3()
(vl-load-com)
(setq path "D:\\great_dcl_chs\\" A_husk "supper\\"Bpath (strcat path "SLD\\") )
(setvar "SECURELOAD" 0) ;關閉安全性提示
(if(setq LOA0 (strcat path A_husk "Great-DCL.fas")) (load LOA0)) ;載入DCL面板轉換程式
(setvar "SECURELOAD" 1) ;打開安全性提示
(setq Dlst '(
":row{"
("image_button" "" "豎直" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "上" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "水平" "16" "8" "" "-2" "#allow_accept=true;")
"}"
":row{"
("image_button" "" "左" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "下" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "右" "16" "8" "" "-2" "#allow_accept=true;")
}
("@image_button" "" "雙向居中" "50" "8" "" "-2" )
)
)
;<< DCL起始對話框函數 >>,第3數為 0 不配置按鈕 ,第4參數為0 不轉換,為 1 轉換為dcl 文字檔
(DCL:STATEDlst "【物體對齊】" 0 1)
(setq dd(DCL:END)) ;<<DCL結束對話框函數 >>
)
可將上面的 Dlst列表串 與下面轉換的dcl 做比較
例上面簡寫程式碼找到此行 ("image_button" "" "豎直" "16" "8" "" "-2" "#allow_accept=true;")
對照下面 透過程式幫你轉成DCL 檔案格式找到轉換後的此行如下
:image_button{ key="豎直"; width=16; height=8; color=-2;allow_accept=true; }
也就是說下面所生成的DCL檔 才是一般我們需要寫的檔案格式
但如今只需透過這個轉換程式
採用上面的簡略格式寫法 + 兩函數 透過參數 1,2,3設定 便可生成DCL檔, DCL轉LSP檔, DCL轉LSP檔(Write 格式)
DCL起始對話框函數 第4參數=1 生成一般的dcl檔 (若要保存需另存新檔) 轉好的DCL 文字檔如下
NextSetting :dialog{ label = "【物體對齊】";
:row{
:image_button{ key="豎直"; width=16; height=8; color=-2;allow_accept=true; }
:image_button{ key="上"; width=16; height=8; color=-2;allow_accept=true; }
:image_button{ key="水平"; width=16; height=8; color=-2;allow_accept=true; }
}
:row{
:image_button{ key="左"; width=16; height=8; color=-2;allow_accept=true; }
:image_button{ key="下"; width=16; height=8; color=-2;allow_accept=true; }
:image_button{ key="右"; width=16; height=8; color=-2;allow_accept=true; }
}
:image_button{ key="雙向居中"; width=50; height=8; color=-2; is_cancel=true; }
}
DCL起始對話框函數 第4參數=2 轉成 dcl-lisp檔另存檔案a2.lsp 如下
;***********************************************************************************************
;<<<<<< 設定 DCL>>>>>>
(defun NextSetting_DCL ()
(not (and (setq dcl_file (open (setq tmp (vl-filename-mktemp nil nil".DCL")) "w"))
(progn
(foreach x
'(
"NextSetting :dialog{"
"label = \"【物體對齊】\";"
":row{"
":image_button{"
"key=\"豎直\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
":image_button{"
"key=\"上\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
":image_button{"
"key=\"水平\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
"}"
":row{"
":image_button{"
"key=\"左\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
":image_button{"
"key=\"下\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
":image_button{"
"key=\"右\";"
"width=16;"
"height=8;"
"color=-2;"
""
"allow_accept=true;"
"}"
"}"
":image_button{"
"key=\"雙向居中\";"
"width=50;"
"height=8;"
"color=-2;"
"is_cancel=true;"
"}"
""
"}"
) (write-line x dcl_file) )
(setq dcl_file (close dcl_file))
(< 0 (setq dcl_id (load_dialog tmp)))
) (if (not (new_dialog "NextSetting" dcl_id)) (exit))
) ) )
(defun c:a2()
;***********************************************************************************************
;<<<<<< 設定 DCL>>>>>>
(vl-load-com) (NextSetting_DCL); 在螢幕上顯示DCL
;;<-- 編輯區1 -->
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq dd (start_dialog))
(unload_dialog dcl_id)
(vl-file-delete tmp)
;;<-- 編輯區2 -->
(cond
((= dd 0) );execute cancel button
((= dd 1) );execute accept button
);end_cond
(princ)
)
儲存檔案名稱即為 指令名稱將a2.lsp載入執行 後 輸入指令 a2 便可顯示空白的幻燈片對話框如圖片所示
DCL起始對話框函數 第4參數=3 轉成 dcl-lisp檔 (write格式)另存檔案a3.lsp 如下
(defun c:a3()
(setq fname (vl-filename-mktemp nil nil ".dcl"))
(setq fn (open fname "w"))
(write-line "NextSetting :dialog{" fn)
(write-line "label = \"【物體對齊】\";" fn)
(write-line ":row{" fn)
(write-line ":image_button{" fn)
(write-line "key=\"豎直\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line ":image_button{" fn)
(write-line "key=\"上\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line ":image_button{" fn)
(write-line "key=\"水平\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line "}" fn)
(write-line ":row{" fn)
(write-line ":image_button{" fn)
(write-line "key=\"左\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line ":image_button{" fn)
(write-line "key=\"下\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line ":image_button{" fn)
(write-line "key=\"右\";" fn)
(write-line "width=16;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "" fn)
(write-line "allow_accept=true;" fn)
(write-line "}" fn)
(write-line "}" fn)
(write-line ":image_button{" fn)
(write-line "key=\"雙向居中\";" fn)
(write-line "width=50;" fn)
(write-line "height=8;" fn)
(write-line "color=-2;" fn)
(write-line "is_cancel=true;" fn)
(write-line "}" fn)
(write-line "" fn)
(write-line "}" fn)
(close fn)
;;************************************
(setq dclid (load_dialog fname))
(new_dialog"NextSetting" dclid)
;;<-- 編輯區1 -->
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq dd (start_dialog))
(unload_dialog dcl_id)
(vl-file-delete tmp)
;;<-- 編輯區2 -->
(cond
((= dd 0) );execute cancel button
((= dd 1) );execute accept button
);end_cond
(princ)
)
儲存檔案名稱即為 指令名稱將a3.lsp載入執行 後 輸入指令 a3 便可顯示空白的幻燈片對話框 如圖片所示
本帖最后由 lee50310 于 2023-6-25 09:09 编辑
假設你已熟讀規則並可自行撰寫 dlst列表 以範例3 幻燈片來說明
下面這個是寫好的 dlst列表可透過轉換函數轉成 DCL檔 (比起一般撰寫DCL檔要簡單方便很多)
(setq Dlst '(
":row{"
("image_button" "" "豎直" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "上" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "水平" "16" "8" "" "-2" "#allow_accept=true;")
"}"
":row{"
("image_button" "" "左" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "下" "16" "8" "" "-2" "#allow_accept=true;")
("image_button" "" "右" "16" "8" "" "-2" "#allow_accept=true;")
}
("@image_button" "" "雙向居中" "50" "8" "" "-2" )
)
)
這是轉換程式Great-DCL.fas內的兩個重要函數 一個是DCL起始函數 及 結束函數 如下
;參數項 1 2 34
(DCL:STATEDlst "【物體對齊】" 01 ) ;DCL起始函數
(setq dd(DCL:END)) ;結束函數
DCL起始函數有4個參數
第1項參數 Dlst 列表項
第2參數 DCL對話框之標題名稱
第3參數 OK或Cancel 按鈕生成選項 參數值 0至 5 詳使用說明
第ˋ4參數 是否生成 dcl文字檔
0 =>不生成
1 =>生成dcl檔
2 =>dcl轉成lisp檔
3 =>dcl轉成lisp檔(Write格式)
建議剛開始編寫 dlst列表 此函數第4 項參數先設0 =>不生成dcl
執行程式 若編寫的 dlst列表無誤 會在cad螢幕顯示 所寫的對話框
若沒顯示出對話框 表示 dlst列表內容有錯誤 須修正
等沒有錯誤 再改此參數 生成你要輸出的項目
本帖最后由 lee50310 于 2023-6-25 06:43 编辑
水洗可口可乐 发表于 2023-6-24 18:09
大佬你这个 有具体应用吗
(需要会 lisp + dcl 写作基础才能看得懂)
这个是应用在 程式写作 需要dcl对话框时ˊ 可用此辅助程式帮助你快速生成dcl 并转成lisp档
可利用转好的 lisp档 继续程式写作节省时间并减少错误
有阿! ! 不是提供 ˊ6 个程式范例
具体应用就要看你要写 哪种( lisp+dcl)程式 例如 你的dcl程式中有 按钮 ,有下拉式选项 ,有点选钮
那 dlst列表 编写方式 可参考 范例的 6.综合.lsp 去改成你要的格式
简单的说 你有看过院长写的(lisp+dcl)程式吗?
是不是 一個列表項 + 简短几个步骤 就生成dcl对话框
若你会写(lisp+dcl)程式 有了这个 转换程式 你也可以 像他一样快速建立
本帖最后由 lee50310 于 2023-6-24 21:36 编辑
將生成後的空白 dcl再自行填入 幻燈片載入路徑,初始參數設定及所需函數即可
大佬又来分享好东西了,好好学学 講真說,我好希望你們改為簡體字,不費眼,新加坡就不錯不守舊 caoliu023 发表于 2023-6-24 16:58
講真說,我好希望你們改為簡體字,不費眼,新加坡就不錯不守舊
他可能不太习惯简体 大佬你这个 有具体应用吗 lee50310 发表于 2023-6-24 18:37
(需要會 lisp + dcl 寫作基礎才能看得懂)
這個是應用在 程式寫作 需要dcl對話框時ˊ 可用此輔助程式幫 ...
谢谢了,我消化一下:L