本帖最后由 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:STATE Dlst "【物體對齊】" 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 如下
儲存檔案名稱即為 指令名稱 將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 便可顯示空白的幻燈片對話框 如圖片所示
|