woodman78 发表于 2022-7-6 14:15:09

单选按钮

我有一个关于对话框单选按钮的问题。每个对话框是否限制一组单选按钮。我想选择两个项目,但我不想使用单选按钮和切换框。每当我尝试输入多组单选按钮时,就会出现错误。
谢谢

Lee Mac 发表于 2022-7-6 14:30:18

不,你可以有多组单选按钮-只需将每组放在不同的“类别”(想不出正确的术语)。
 
例如:
http://www.cadtutor.net/forum/showthread.php?t=33919

The Buzzard 发表于 2022-7-6 14:48:32

 
我用了你的samp4。dcl和samp4。以lsp为例,添加另一列单选按钮。
 
DCL
samp4 : dialog {                               //*dialog name
       label = "Existing Storm Sewers" ;      //*give it a label
       : row {                              //*define row
         : column {                           //*define column
         : boxed_radio_column {             //*define radio column
             label = "Choose a Type" ;      //*give it a label
             : radio_button {               //*define radio_button
               key = "T1";                  //*give it a name
               label = "Type 1";            //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "T2";                  //*give it a name
               label = "Type 2";            //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "T3";                  //*give it a name
               label = "Type 3";            //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "T4";                  //*give it a name
               label = "Type 4";            //*give it a label
             }                              //*end radio_button
         }                                  //*end boxed_radio_column
         }                                    //*end column
         : column {                           //*define column
         : boxed_radio_column {             //*define radio column
             label = "Choose a Whatever" ;    //*give it a label
             : radio_button {               //*define radio_button
               key = "W1";                  //*give it a name
               label = "Whatever 1";          //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "W2";                  //*give it a name
               label = "Whatever 2";          //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "W3";                  //*give it a name
               label = "Whatever 3";          //*give it a label
             }                              //*end radio_button
             : radio_button {               //*define radio_button
               key = "W4";                  //*give it a name
               label = "Whatever 4";          //*give it a label
             }                              //*end radio_button
         }                                  //*end boxed_radio_column
         }                                    //*end column
       }                                    //*end row
       ok_cancel ;                            //*predifined OK/Cancel
       : row {                              //*define row
         : paragraph {                        //*define paragraph
         : text_part {                      //*define text
             label = "Designed by BD";      //*give it some text
         }                                  //*end text
         : text_part {                      //*define more text
             label = "for CCC NNRDO";         //*some more text
         }                                  //*end text
         }                                    //*end paragraph
       }                                    //*end row
   }                                        //*end dialog
LSP
(defun C:samp4 (/ hole) ;define function
(setq dcl_id (load_dialog "samp4.dcl")) ;load dialog
(if
   (not (new_dialog "samp4" dcl_id) ;test for dialog
   );not
   (progn
   (alert "Can not find your dcl file")
   (exit) ;exit if no dialog
   )
);if
(set_tile "T1" "1")   ;Set radio_button T1 as default
(set_tile "W1" "1")   ;Set radio_button W1 as default
(setq hole "TB1")   ;Set variable hole to TB1 as default
(setq Whatever "WB1") ;Set variable whatever to WB1 as default
(action_tile "T1" "(setq hole \"TB1\")") ;*store hole type
(action_tile "T2" "(setq hole \"TB2\")") ;*store hole type
(action_tile "T3" "(setq hole \"TB3\")") ;*store hole type
(action_tile "T4" "(setq hole \"TB4\")") ;*store hole type
(action_tile "W1" "(setq whatever \"WB1\")") ;*store whatever
(action_tile "W2" "(setq whatever \"WB2\")") ;*store whatever
(action_tile "W3" "(setq whatever \"WB3\")") ;*store whatever
(action_tile "W4" "(setq whatever \"WB4\")") ;*store whatever
(action_tile "cancel" ;if cancel button pressed
"(done_dialog)(setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile "accept" ;if O.K. pressed
"(done_dialog)(setq userclick T))" ;??? Is this standard code.
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if userclick                        ;When OK button is selected
   (cond                              ;And one of the following conditions apply
   ((= hole "TB1")(C:ESS1500))      ;If TB1 selected, Go to C:ESS1500
   ((= hole "TB2")(C:ESS1350))      ;If TB2 selected, Go to C:ESS1350
   ((= hole "TB3")(C:ESS1200))      ;If TB3 selected, Go to C:ESS1200
   ((= hole "TB4")(C:ESS1050))      ;If TB4 selected, Go to C:ESS1050
    ;(t (princ "\nNothing changed.")) ;_ end of optional else condition
   )                                  ;End cond
)                                    ;End if
(princ)                              ;Exit quietly
)                                    ;End defun
(princ "\nThis loaded fine")
(princ)
;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; Start
(defun C:ESS1500()
(setq a "CCC_DR_1500")
(if (= (tblsearch "ltype" a) nil)
      (command "-linetype" "l" a "acadiso.lin" "")
            (princ))
(graphscr)
(command "._-layer" "N" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500"
                     "M" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500"
                     "L" "CCC_DR_1500""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500"
                     "C""84""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500"
                     "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1500" "" )
(command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0")
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1500mm;;;;;;;;;; End

;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; Start
(defun C:ESS1350()
(setq a "CCC_DR_1350")
   (if (= (tblsearch "ltype" a) nil)
   (command "-linetype" "l" a "acadiso.lin" "")
            (princ))
(graphscr)
(command "._-layer" "N""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350"
                     "M""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350"
                     "L""CCC_DR_1350""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350"
                     "C""84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350"
                     "LW" "0.3"   "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1350" "" )
(command "pline" pause "width" "0.0" "0.0" pause "width" "0.0" "0.0")
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1350mm;;;;;;;;;; End

;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; Start
(defun c:ESS1200()
(setq a "CCC_DR_1200")
(if (= (tblsearch "ltype" a) nil)
      (command "-linetype" "l" a "acadiso.lin" "")
            (princ))
(graphscr)
(command "._-layer" "N""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200"
                     "M""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200"
                     "L""CCC_DR_1200""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200"
                     "C""84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200"
                     "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1200" "" )
(command "pline" pause "width" "0.0" "0.0")
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1200mm;;;;;;;;;; End

;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; Start
(defun c:ESS1050()
(setq a "CCC_DR_1050")
(if (= (tblsearch "ltype" a) nil)
      (command "-linetype" "l" a "acadiso.lin" "")
            (princ))
(graphscr)
(command "._-layer" "N""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050"
                     "M""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050"
                     "L""CCC_DR_1050""CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050"
                     "C""84" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050"
                     "LW" "0.3" "CCC_SERVICES_EXISTING_Drainage_Storm_Sewer_1050" "" )
(command "pline" pause "width" "0.0" "0.0")
(princ)
)
;;;;;;;;;;Existing Storm_Sewer 1050mm;;;;;;;;;; End
 
所有更改均为红色。

flowerrobot 发表于 2022-7-6 14:51:49

buzzard先生
 
你为什么不使用单选按钮组?
因为它所需要的只是一个“ok”点上的cond&action互动程序?
 
: boxed_radio_column {            
label = "Choose a Whatever" ;
key = "Group_radio_1")
: radio_button {               
            key = "W1";   
etc...

(set_tile "Group_radio_1" 0)
(action_tile "ok" (setq hi (get_tile "Group_radio_1"))
(cond
((= hi 0)(setq hole "WB1"))
)


 
 
只是询问一下,因为你做dcl的时间比我长得多

The Buzzard 发表于 2022-7-6 15:08:44

 
我学习的方式似乎适合我。

flowerrobot 发表于 2022-7-6 15:21:23

这是一个很好的理由
页: [1]
查看完整版本: 单选按钮