AutoCAD顧問
還沒有註冊嗎...即日起免費註冊,所有最完整的AutoCAD討論、教學及資源都在論壇裡喔~

Join the forum, it's quick and easy

AutoCAD顧問
還沒有註冊嗎...即日起免費註冊,所有最完整的AutoCAD討論、教學及資源都在論壇裡喔~
AutoCAD顧問
Would you like to react to this message? Create an account in a few clicks or log in to continue.
[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ioaoe110[已解決]設定下拉式選單popup_list,執行時切換會跑掉 2020-310[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Oiu15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 2020-211[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ia15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aizyao10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Uos15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 BPl3tjj[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ziao1510
[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Oo-2-110[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Zuoiy_10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aizyao11[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Iyb_1510[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe1-111[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Uos15011[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe2da10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe2da11[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe10

[已解決]設定下拉式選單popup_list,執行時切換會跑掉

3 posters

向下

[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Empty [已解決]設定下拉式選單popup_list,執行時切換會跑掉

發表 由 swcforest 周二 6 4月 2010 - 13:26

節錄部分程式
(setq list1 '("S50" "S100" "S200" "S400" "S500" "S600" "S800" "S1000"))

(show_list "k1" list1)
(action_tile "k1" "(sub_pop1 $value)")

(setq dimstyle1 (get_tile "k1"))
(cond ((= dimstyle1 "0") (setq dimstyle1 "S50"))
((= dimstyle1 "1") (setq dimstyle1 "S100"))
((= dimstyle1 "2") (setq dimstyle1 "S200"))
((= dimstyle1 "3") (setq dimstyle1 "S400"))
((= dimstyle1 "4") (setq dimstyle1 "S500"))
((= dimstyle1 "5") (setq dimstyle1 "S600"))
((= dimstyle1 "6") (setq dimstyle1 "S800"))
((= dimstyle1 "7") (setq dimstyle1 "S1000"))
)
;;;副程式
(defun sub_pop1 ($v)
(set_tile "k1" (nth (atoi $v) list1))
)

;;;DCL
:popup_list{label="標註型式";edit_width=7;key="k1";value="2";}
每次在執行的時候,雖然我的預設值dimstyle1 是 s200
只要切換想要用s100或其他
就會跑到s50
但是只要我改 (setq list1 '("50" "100" "200" "400" "500" "600" "800" "1000"))
就可以
若是改 (setq list1 '("1-50" "1-100" "1-200" "1-400" "1-500" "1-600" "1-800" "1-1000"))
就又不行了 請問各位前輩是哪邊有問題嗎
謝謝



謝謝大大提供解答
感激萬分


swcforest 在 周五 16 4月 2010 - 20:56 作了第 1 次修改
avatar
swcforest
初級會員
初級會員

文章總數 : 113
年齡 : 44
來自 : 台中市南區
職業 : 土木工程設計
愛好 : 遊山玩水及AutoLISP
個性 : 開朗活潑
使用年資 : 六七年了
使用版本 : AutoCAD 2016
積分 : 1
經驗值 : 6027
威望值 : 10
注冊日期 : 2008-07-27
男 天秤座 羊

回頂端 向下

[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Empty 回復: [已解決]設定下拉式選單popup_list,執行時切換會跑掉

發表 由 shenhung 周一 12 4月 2010 - 8:59

dimstyle1 已經是key "k1"的index 必須為一個整數字串值..但.後面又是list1所取出的值..2者是不一樣的東西.不能設為同一個變數名.否則dimstyle1值會變取帶掉.一定會錯誤..所以.你list1取出的值.要令外取名.改為dimstyle2 我沒你完整程式不能幫你測..你試試看...祝你好運

(cond ((= dimstyle1 "0") (setq dimstyle2 "S50"))
((= dimstyle1 "1") (setq dimstyle2 "S100"))
((= dimstyle1 "2") (setq dimstyle2 "S200"))
((= dimstyle1 "3") (setq dimstyle2 "S400"))
((= dimstyle1 "4") (setq dimstyle2 "S500"))
((= dimstyle1 "5") (setq dimstyle2 "S600"))
((= dimstyle1 "6") (setq dimstyle2 "S800"))
((= dimstyle1 "7") (setq dimstyle2 "S1000"))
)
shenhung
shenhung
高級會員
高級會員

文章總數 : 272
年齡 : 57
來自 : 新北市
職業 : 塑膠模具設計.AUTOLISP
愛好 : 音樂
個性 : 隨和
使用年資 : 18年
使用版本 : 2010
積分 : 15
經驗值 : 7782
威望值 : 1157
注冊日期 : 2009-06-03
男 摩羯座 馬

回頂端 向下

[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Empty 回復: [已解決]設定下拉式選單popup_list,執行時切換會跑掉

發表 由 張譽璋 周二 20 4月 2010 - 7:25

建議你下拉功能表預設值或下拉清單最好寫在DCL檔中,如下例
代碼:

                    : popup_list {
                        label = "字型設定:";
                        key  = "sty";
                        edit_width = 15;
                        list = "STANDARD\nSTANDARD1\n點陣字";
                        value = 0;
                    }
                    : popup_list {
                        label = "      字高設定:";
                        key  = "sth";
                        edit_width = 3;
                        list = "3\n3.5\n4\n4.5\n5\n6\n7\n8";
                        value = 5;
                    }
這樣預設值就不會跑掉,寫在程式中的方法資料是需要處理或轉換的,我想你的程式中的問題因該更資料及變數的使用有很大的關係
你現在的寫法應該是參考書上寫的方式,但是這樣的寫法你就必須將資料處理好不然會出現不正常的,下列是LSP中的寫法與上述DCL
程式對應

代碼:
  (defun ok ()
    (setq sty (get_tile "sty"))
    (setq sth (get_tile "sth"))
    (done_dialog 1)
  )
  (cond ((= sty "0") (setvar "textstyle" "STANDARD"))
        ((= sty "1") (setvar "textstyle" "STANDARD1"))
        ((= sty "2") (setvar "textstyle" "點陣字"))
  )
  (cond ((= sth "0") (setq sth (* 3.0 (getvar "userr1")) hl 6.0))
        ((= sth "1") (setq sth (* 3.5 (getvar "userr1")) hl 6.5))
        ((= sth "2") (setq sth (* 4.0 (getvar "userr1")) hl 7.0))
        ((= sth "3") (setq sth (* 4.5 (getvar "userr1")) hl 7.5))
        ((= sth "4") (setq sth (* 5.0 (getvar "userr1")) hl 8.0))
        ((= sth "5") (setq sth (* 6.0 (getvar "userr1")) hl 9.0))
        ((= sth "6") (setq sth (* 7.0 (getvar "userr1")) hl 10.0))
        ((= sth "7") (setq sth (* 8.0 (getvar "userr1")) hl 11.0))
  )
這樣應該可以解決你的問題了
avatar
張譽璋
榮譽顧問
榮譽顧問

文章總數 : 304
年齡 : 53
來自 : 彰化縣員林鎮
職業 : 機械設計工程師/AutoCAD講師/AutoCAD外掛系統開發/AutoCAD書籍作者
愛好 : 旅行及電影
個性 : 風趣健談
使用年資 : 25年
使用版本 : AutoCAD2010/2011/2012/2013
積分 : 20
經驗值 : 7304
威望值 : 641
發帖精華 : 2
回帖精華 : 1
注冊日期 : 2008-05-28
藍鵲12號
男 處女座 狗

回頂端 向下

[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Empty 回復: [已解決]設定下拉式選單popup_list,執行時切換會跑掉

發表 由 張譽璋 周三 21 4月 2010 - 7:17

你可以將你的原來寫法改為如下
代碼:
(setq list1 '("50" "100" "200" "400" "500" "600" "800" "1000"))

(show_list "k1" list1)
(action_tile "k1" "(sub_pop1 $value)")

(setq dimstyle1 (get_tile "k1"))
(cond ((= dimstyle1 "0") (setq dimstyle1 (strcat "50"))
((= dimstyle1 "1") (setq dimstyle1 "100"))
((= dimstyle1 "2") (setq dimstyle1 "200"))
((= dimstyle1 "3") (setq dimstyle1 "400"))
((= dimstyle1 "4") (setq dimstyle1 "500"))
((= dimstyle1 "5") (setq dimstyle1 "600"))
((= dimstyle1 "6") (setq dimstyle1 "800"))
((= dimstyle1 "7") (setq dimstyle1 "1000"))
)
(setq dimstyle1 (strcat "S" dimstyle1));加入這行,利用合併字串的方式解決
avatar
張譽璋
榮譽顧問
榮譽顧問

文章總數 : 304
年齡 : 53
來自 : 彰化縣員林鎮
職業 : 機械設計工程師/AutoCAD講師/AutoCAD外掛系統開發/AutoCAD書籍作者
愛好 : 旅行及電影
個性 : 風趣健談
使用年資 : 25年
使用版本 : AutoCAD2010/2011/2012/2013
積分 : 20
經驗值 : 7304
威望值 : 641
發帖精華 : 2
回帖精華 : 1
注冊日期 : 2008-05-28
藍鵲12號
男 處女座 狗

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章
[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ioaoe110[已解決]設定下拉式選單popup_list,執行時切換會跑掉 2020-310[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Oiu15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 2020-211[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ia15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aizyao10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Uos15010[已解決]設定下拉式選單popup_list,執行時切換會跑掉 BPl3tjj[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Ziao1510
[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Oo-2-110[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Zuoiy_10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aizyao11[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Iyb_1510[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe1-111[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Uos15011[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe2da10[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe2da11[已解決]設定下拉式選單popup_list,執行時切換會跑掉 Aoe10