Jump to content

Recommended Posts

Posted

Hi,

 

I have a problem to change contents in pop_up lists.

 

I have two radio buttons "sp" and "dp" and two popup list. When I activate one of this buttons I want one type of contents in the popup_lists and when I activate the other button I want another contents in the popup_lists. How to do?. I have tested the code below but it doesnt work

 

 
(defun saveVars()
 (setq mychoice(get_tile "size"))
)
(action_tile "sp"
 "(start_list \"rep\" 3)
  (cond (= mychoise \"str_s2\") (mapcar 'add_list mylist8))
  (cond (= mychoise \"str_s3\") (mapcar 'add_list mylist70))
  (cond (= mychoise \"str_m2\") (mapcar 'add_list mylist72))   
  (end_list)"
)
 
(action_tile "tp"
 "(start_list \"rep\" 3)
  (cond (= mychoise \"str_s2\") (mapcar 'add_list mylist9))
  (cond (= mychoise \"str_s3\") (mapcar 'add_list mylist71))
  (cond (= mychoise \"str_m2\") (mapcar 'add_list mylist73))    
  (end_list)"
)

 

/Dan

Posted

mychoise or mychoice, that is the problem!

Posted

Hi,

 

I have tested "if" but that doesnt work. How to write the code?

 

/Dan

Posted (edited)
(cond 
     (   (= mychoise \"str_s2\")  (mapcar 'add_list mylist8)  )
     (   (= mychoise \"str_s3\")  (mapcar 'add_list mylist70) )
     (   (= mychoise \"str_m2\") (mapcar 'add_list mylist72) ) 
  )
  (end_list)"

Edited by SLW210
Posted

Did you have change mychoice to suitable with mychoise ?

(defun saveVars()

(setq mychoice(get_tile "size"))

)

BTW, you used a wrong way syntax of COND

Posted

Hi,

 

I have two choises "sp" and "tp". Depending of my choises I want different contents in popup lists. Can you help me. I'm going crazy!

 

 

 
(defun saveVars()
 
 (setq mypan(get_tile "panel"))
 ;;(setq mychoice(get_tile "sizecab"))
 (setq size1(atoi(get_tile "str_s2")))
 (setq size2(atoi(get_tile "str_m2")))
 (setq size3(atoi(get_tile "str_l2")))
 (setq size4(atoi(get_tile "str_s3")))
 (setq size5(atoi(get_tile "str_m3")))
 (setq size6(atoi(get_tile "str_l3")))
 (setq mypump1(atoi(get_tile "sp")))
 (setq mypump2(atoi(get_tile "tp")))
 (setq myspider1(atoi(get_tile "phs")))
 (setq myspider2(atoi(get_tile "pud")))
 (setq myspider2(atoi(get_tile "i_spid")))  
 ;;;--- Get the selected item from the first list
 (setq sStr1(get_tile "mylist1"))
 (setq sStr20(get_tile "mylist20"))
 (setq sStr21(get_tile "mylist21"))  
 (setq sStr13(get_tile "rep")) 
)

 ;;;--- Make sure something was selected... 
 ;;(if(= sStr1 "")> 
   ;;(setq myItem1 "Nothing") 
   ;;(setq myItem1 (nth (atoi sStr1) myList1)) 
 ;
  ;;(cond ((= choice2 1)(princ "Tank")))
;;(cond ((= choice1 1)(setq myList1(list  "" "Height 600 mm" "Height 700 mm" "Height 800 mm"))))

 

 (defun FillPopupList1 ( key1 lst1 )
   (start_list key1)
   (foreach item lst1 (add_list item))
   (end_list)   
   )
 (defun FillPopupList2 ( key2 lst2 )
   (start_list key2)
   (foreach item1 lst2 (add_list item1))
   (end_list)   
   )

(setq a 0)
(setq b 0)
(setq c 0)
(setq d 0)
(setq e 0)
(setq f 0)
(setq g 0)

(defun C:DUE_DIM()


(setq myList2(list "" "---ABB---" "75 kW" "90 kW" "110 kW" "132 kW" "160 kW" "200 kW" "--Siemens--"))
(setq myList3(list "" "---ABB---" "250 kW" "315 kW" "355 kW" "400 kW" "500 kW" "--Siemens--"))
(setq myList70(list  "1" "SP71" "SP125" "Sp180"))  
(setq myList71(list  "2" "SP180" "SP250" "Sp500"))
(setq myList72(list  "3" "SP180/180" "SP250/125" "SP250/250" "SP355/250" "SP355/355" "SP500/250" "SP500/355"))
(setq myList73(list  "4" "SP180" "SP250" "Sp500" "Sp750"))  
(setq myList74(list  "5" "SP180/180" "SP250/125" "SP250/250" "SP355/250" "SP355/355" "SP500/250" "SP500/355" "SP500/500")) 

   
(setq myList8(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))
(setq myList9(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))
(setq myList10(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))
(setq myList11(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))
(setq myList12(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))
(setq myList13(list  "" "-VATTENKYLARE-" "B025T040"  "B025T080" "B120T060" "B120T080" "B120T120" "-TUBKYLARE-" "000GK400" "000GK600" "000PK600" "000PK600"
     "-LUFTKYLARE-" "HDCA-100-4" "HDCA-145-4" "HDCA-205-4" "HDCA-275-4" "HDCA-360-6" "HDCA-490-6" "HDCA-700-6" "HDCA-710-6" "HDCA-1250-8"))  
 
(setq rep(list "Ingen" "Flushing via backventil" "Flushing extern pump" "Flushing+Broms1" "Flushing+Broms1+Broms2" "Broms1" "Broms1+Broms2"))   

 
 ;;;--- Load the dcl file
 (setq dcl_id (load_dialog "dimritn6.dcl"))
 ;;;--- Load the dialog definition if it is not already loaded
 (if (not (new_dialog "dimdialog6" dcl_id))
   (progn
    (alert "The SAMPLE4.DCL file could not be loaded!")
     (exit)
   )
 )
 ;;;--- If an action event occurs, do this function
 (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
 (action_tile "cancel" "(setq ddiag 1)(done_dialog)")

 (start_list "mylist7" 3)
   (mapcar 'add_list myList8)
 (end_list)
 


 (start_list "rep" 3)
 (mapcar 'add_list rep) 
 (end_list)


 
 ;;(action_tile "str_s2sp" "(FillPopupList1 \"mylist20\" mylist1)(FillPopupList2 \"mylist21\" mylist70)")
 ;;(action_tile "str_m2sp" "(FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist71)")
 ;;(action_tile "str_m2tp" "(FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist72)")
 ;;(action_tile "str_l2sp" "(FillPopupList1 \"mylist20\" mylist3)(FillPopupList2 \"mylist21\" mylist73)")
 ;;(action_tile "str_l2tp" "(FillPopupList1 \"mylist20\" mylist3)(FillPopupList2 \"mylist21\" mylist74)")
 ;;(action_tile "str_s3sp" "(FillPopupList1 \"mylist20\" mylist1)(FillPopupList2 \"mylist21\" mylist70)")  
 ;;(action_tile "str_m3sp" "(FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist71)")
 ;;(action_tile "str_m3tp" "(FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist72)")  
 ;;(action_tile "str_l3sp" "(FillPopupList1 \"mylist20\" mylist3)(FillPopupList2 \"mylist21\" mylist73)")
 ;;(action_tile "str_l3" "(FillPopupList1 \"mylist20\" mylist3)(FillPopupList2 \"mylist21\" mylist74)")
(action_tile "sp"
 "(start_list \"mylist20\" 3)
  (FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist70)
(end_list)"
)
 
(action_tile "tp"
 "
 (cond 
   ( (= size1 \"1\") (FillPopupList1 \"mylist20\" mylist2)(FillPopupList2 \"mylist21\" mylist70) )
   ( (= size2 \"1\") (FillPopupList1 \"mylist20\" mylist3)(FillPopupList2 \"mylist21\" mylist71) )
   ( (= size3 \"1\") (FillPopupList1 \"mylist20\" mylist4)(FillPopupList2 \"mylist21\" mylist72) ) 
 )
" 
)


   (action_tile "ej_pan"
    "(mode_tile \"sp\" 1)
     (mode_tile \"tp\" 1)
     (mode_tile \"pid\" 1)   
     (mode_tile \"pud\" 1)"
)
   (action_tile "med_pan"
    "(mode_tile \"sp\" 0)
     (mode_tile \"tp\" 0)
     (mode_tile \"pid\" 0)      
     (mode_tile \"pud\" 0)"
)
 
   (action_tile "med_ljudo"
    "(mode_tile \"sp\" 0)      
     (mode_tile \"tp\" 0)
     (mode_tile \"pid\" 0)      
     (mode_tile \"pud\" 0)"
     
)
   (princ mychoise)
 
 ;;;--- Display the dialog box
 (start_dialog)
 ;;;--- Unload the dialog box
 (unload_dialog dcl_id)
 ;;;--- If the user pressed the Cancel button
 (if(= ddiag 1)
   (princ "\n Sample4 cancelled!")
 )

 ;;;--- If the user pressed the Okay button
 (if(= ddiag 2)
   (progn 
     (if (= mychoice "str_s2")(setq a "1")(setq b 0))
     (if (= mychoice "str_m2")(setq a "2")(setq b 0))
     (if (= mychoice "str_l2")(command "_.script" "T:\\DUE\\Dimritning\\L3\\script\\DUe_stativL2.scr")(setq b 0))
     (if (= mychoice "str_s3")(setq a "4")(setq b 0))
     (if (= mychoice "str_m3")(setq a "5")(setq b 0))
     (if (= mychoice "str_l3sp")(setq a "6")(setq b 0))     
     (if (= mypan "ej_pan")(setq c "1")(setq d 0));;Utan paneler
     (if (= mypan "med_pan")(setq c "2")(setq d 0));;Med paneler
     (if (= mypan "med_ljudo")(setq c "3")(setq d 0));;Med paneler + ljudoption      
     (if (= mypump1 1)(setq e "1")(setq e "2"));; Singel eller tandempump
     (if (= myspider1 1)(setq f "1")(setq f "2"));; Spider vänster eller höger sida
     
     (if (= myspider2 1)(setq g "1")(setq g "2"));; Spiderpanel utanför dörr eller innanför
     
      (cond
       ((= myChoice "str_s2sp")
 (progn
 (princ "\n Using Radio_column data...You chose ")
 (princ str_s2)
 (princ "Stativ S2")
 (princ "\n Using Radio_column data...You chose ")
          (cond
            ((= sStr1 "1")(princ "S2Höjd 320 mm"))
   )
 )
        )

       ((= myChoice "str_m2sp")
        (progn
 (princ "\n Using Radio_column data...You chose ")
 (princ "Stativ M2")
 (princ "\n Using Radio_column data...You chose ")
          (cond
            ((= sStr2 "1")(princ "M2Höjd 320 mm"))
   )
 )
      )
;; Stativ L3
       ((= myChoice "str_l3sp")
 (setq L3_val(strcat f a))
 (setq L3_topp(strcat sStr6 f))  
 (cond ((= L3_val "26")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\DUe_stativL3_v.dwg" "0,0" "1" "1" "0")))  
 (cond ((= L3_val "16")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\DUe_stativL3_h.dwg" "0,0" "1" "1" "0")))
        (progn
          (cond
     ((= sStr6 "1")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_600.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "2")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_700.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "3")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_800.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "4")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_900.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "5")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1000.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "6")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1100.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "7")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1200.dwg" "0,0" "1" "1" "0"))
     ((= sStr6 "8")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1300.dwg" "0,0" "1" "1" "0"))      
     ((= sStr6 "9")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1400.dwg" "0,0" "1" "1" "0"))      
     ((= sStr6 "10")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1500.dwg" "0,0" "1" "1" "0"))     
     ((= sStr6 "11")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3_1600.dwg" "0,0" "1" "1" "0"))   
     ((= L3_topp "121")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3v_1700.dwg" "0,0" "1" "1" "0"))
     ((= L3_topp "122")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\toppkåpa_L3h_1700.dwg" "0,0" "1" "1" "0"))      
     
   )
 )
        (progn
    (setq pan_val(strcat c e a));;Insättning panelsammanställning utan spider
    (cond
     ((= pan_val "226")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\panel_L3v_ing_ljudop_isp_tp.dwg" "0,0" "1" "1" "0"))      
     ((= pan_val "316")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\panel_L3v_ljudop_pan_isp_sp.dwg" "0,0" "1" "1" "0"))      
     ((= pan_val "326")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\panel_L3v_ljudop_pan_isp_tp.dwg" "0,0" "1" "1" "0"))
     )
     )

       (progn
   (setq spid(strcat c f a))
          (cond
     ((= spid "326")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\spider_L3v.dwg" "0,0" "1" "1" "0"))
     ((= spid "316")(command "_.insert" "T:\\DUE\\Dimritning\\L3\\komp\\spider_L3h.dwg" "0,0" "1" "1" "0"))
     )
          )
       
        (progn
          (cond
            ((= sStr9 "1")(princ "kYLARE1"))
            ((= sStr9 "2")(princ "kYLARE2"))
            ((= sStr9 "3")(princ "kYLARE3"))
     ((= sStr9 "4")(princ "kYLARE4"))
     ((= sStr9 "5")(princ "kYLARE5"))
     ((= sStr9 "5")(princ "kYLARE6"))
     ((= sStr9 "7")(princ "kYLARE7"))
     ((= sStr9 "8")(princ "kYLARE8"))
     ((= sStr9 "9")(princ "kYLARE9"))
     ((= sStr9 "10")(princ "kYLARE10"))
   
  )  
       )       
    ) 
)
)
    )
 ;;;--- Suppress the last echo for a clean exit
 (princ)
)

Posted

Here is dummy example but it make sence for you I hope

========== LSP ==========

 
(defun C:demo(/ dcl_id )
(cond ((<= (setq dcl_id (load_dialog "popup-choice.dcl")) 0)
(princ "\nPlace dialog definition in current folder"))
( (not (new_dialog "choices" dcl_id))
(princ "\nCheck dialog definition name"))
(t
;; set up dummy values:
(setq str_s2 "1")
(setq str_s3 "2")
(setq str_m2 "3")

(setq mylist8 (mapcar 'itoa '(11 22 33)))
(setq mylist70 (mapcar 'itoa '(110 220 330)))
(setq mylist72 (mapcar 'itoa '(111 222 332)))

(setq mylist9 (mapcar 'itoa '(101 202 303)))
(setq mylist71 (mapcar 'itoa '(114 224 334)))
(setq mylist73 (mapcar 'itoa '(115 225 335)))

(setq sizes '("1" "2" "3"))
(action_tile "size" "(setq mychoise (nth (atoi $value) sizes))")

(action_tile "rep" "(setq selected (nth (atoi $value) source))")

(action_tile "accept" "(done_dialog 1)")

(action_tile "cancel" "(done_dialog 0)")
(setq result (start_dialog))
(unload_dialog dcl_id)))
(if (= 1 result)
(alert (strcat "Mychoise: " mychoise"\nSelected: " selected)))
;; do your mojo here
(princ)
)

========= DCL =========

 
//dcl_settings : default_dcl_settings { audit_level = 3 ; }
choices : dialog {
label = "Test Popup" ;
spacer;
:boxed_column {
width=20;
: popup_list {
label = "Size ";
key = "size" ;
list="\n1\n2\n3";
width=15;
}
: popup_list {
label = "Popup";
key = "rep" ;
width=15;
}
spacer; 
}
: boxed_radio_row {
: radio_button {
label="Choice #1";
key="sp";
value="0";
action="(if (= \"1\" $value)(progn "
"(start_list \"rep\" 3)"
"(cond ((= mychoise str_s2)(setq source mylist8) )"
"((= mychoise str_s3)(setq source mylist70) )"
"((= mychoise str_m2)(setq source mylist72) ))"
"(mapcar 'add_list source)"
"(end_list)))";
}
: radio_button {
label = "Choice #2";
key = "tp";
value="0";
action="(if (= \"1\" $value)(progn "
"(start_list \"rep\" 3)"
"(cond ((= mychoise str_s2) (setq source mylist9))"
"((= mychoise str_s3)(setq source mylist71) )"
"((= mychoise str_m2)(setq source mylist73) ))"
"(mapcar 'add_list source)"
"(end_list)))";
}
}
spacer;
ok_cancel ;
}

Posted

Hi fixo,

 

Thanks for the fast coding and answer. This is what i'm looking for. One thing, when I have selected for example "choise #1" and change size from 1 to 2 the popup list will not be updated until I hit "choise #1" again.Is it possible to solve?.

 

Thanks

 

Dan

Posted

Just from the top of my head,

You have to select item from 'size' list first,

sorry, I haven't have a time to show you much now

Posted

Hi fixo,

 

I don't know if you have the time, but I have one more issue. You seems to be very skilled at autolisp.

 

My problem is that when I push radio_button "str_l2sp" contents mylist3 fills mylist20 (that works). Problem I have is depending of the choise in mylist20 I want to have different contents in mylist 21.

Do you know how to do that?

 

 

 

 

 

 
 : radio_button {         // defines the old-style polyline radio button
  label = "&Large 2D Singel";
  key = "str_l2sp";
         value="0";   
  action="(if (= \"1\" $value)(progn "
         "(mode_tile \"mylist21\" 1)"
                          "(start_list \"mylist20\" 3)"                   
                          "(mapcar 'add_list mylist3)"
                          "(end_list)))"
                          "(start_list \"mylist21\" 3)"
                          "(cond ((= mychoise 1)(setq source mylist3) )"
                          "((= mychoise 2)(setq source mylist70) )"
                          "((= mychoise 3)(setq source mylist72) ))"
                          "(mapcar 'add_list source)"
                          "(end_list)))";
                }

 

 
(action_tile "mylist20" 
"(setq mychoise $value)
(mode_tile \"mylist21\" 0)
 ")

 

Regards

 

Dan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...