CadFrank 发表于 2022-7-5 20:11:47

DCL - Popup_list

Hi,
 
I am trying to input more then 1 list in a popup list according to the radio button selected.
 
rigth not I was only able to make 1 appear.
 
Can some guide me in the right direction please.
 
Cheers
 
here are the codes : TEST.lsp
TEST.dcl

Lee Mac 发表于 2022-7-5 20:17:11

You will need to include the operations that are used to populate the popup_list tile within the action_tile statement, so that the operations are performed when the tile value is modified.
 
I would suggest something using this approach:

(defun c:test ( / i id lst )   (setq lst      '(         ("rb1" " " " Mètre" " Kilomètre" " Pied" " Pouce")         ("rb2" " " " Kilomètre carrée" " Mètre carrée" " Pied carrée" " Pouce carrée")       )   )   (if (and (< 0 (setq id (load_dialog "test.dcl"))) (new_dialog "bienvenue" id))       (progn         (repeat (setq i 7)               (action_tile (strcat "rb" (itoa i))                  (strcat                     "(addlist \"list_1\" (cdr (assoc $key lst)))"                     "(addlist \"list_2\" (cdr (assoc $key lst)))"                   )               )               (setq i (1- i))         )         (start_dialog)       )   )   (if (< 0 id) (unload_dialog id))   (princ))(defun addlist ( key lst )   (start_list key)   (foreach x lst (add_list x))   (end_list)   lst)(The above is untested)

Ahankhah 发表于 2022-7-5 20:20:03

CadFrank,
change your code as follows:
 

(defun c:test (/ _test Id)(defun _test (typ) (cond((= Typ "Long")   (start_list "list_1")   (mapcar 'add_list longueur1)   (end_list)   (start_list "list_2")   (mapcar 'add_list longueur1)   (end_list))((= Typ "Surf")   (start_list "list_1")   (mapcar 'add_list surface1)   (end_list)   (start_list "list_2")   (mapcar 'add_list surface1)   (end_list)) ))(setq longueur1 '(" " " Mètre" " Kilomètre" " Pied" " Pouce"))(setq surface1 '(" " " Kilomètre carrée" " Mètre carrée" " Pied carrée" " Pouce carrée"))(setq Id (load_dialog "X:\\Documents\\AutoCAD\\Support\\TEST.dcl"))(if (not (new_dialog "bienvenue" Id)) (exit))(action_tile "rb1" "(_test \"Long\")")(action_tile "rb2" "(_test \"Surf\")")(action_tile "rb3" "(_test \"Vol\")")(action_tile "rb4" "(_test \"Poid\")")(action_tile "rb5" "(_test \"Force\")")(action_tile "rb6" "(_test \"Pres\")")(action_tile "rb7" "(_test \"Mom\")")(action_tile "Close" "(done_dialog) (setq userclick nil)")(start_dialog)(unload_dialog id) (princ))

Ahankhah 发表于 2022-7-5 20:23:12

It was very marvelous,
I think Lee sent his reply seconds before me.

CadFrank 发表于 2022-7-5 20:25:12

 
Well I think you understood what I wanted to do.
 
Hope I can understand the code. Thanks Lee.
 
and also Thanks to Ahankhah. Ill look up your code to !
 
Cheers !

CadFrank 发表于 2022-7-5 20:29:35

 
Hi Lee,
 
I've tested your code and it only keep the last value in mind. So only the moment as.
 
Don't know why but ill look it up more if you have any idea why let me know.
 
Cheers

Lee Mac 发表于 2022-7-5 20:32:38

 
Please note:
 


[*]Only the lists for tiles rb1 & rb2 are defined, you need to define the rest.
[*]The example code does not store any selected values, it simply displays the new list content following a radio button selection.

Ahankhah 发表于 2022-7-5 20:35:51

 
 
You are welcome CadFrank.
 
 
I just revised slightly your own code, and as I tested, it works well.

CadFrank 发表于 2022-7-5 20:40:06

 
Haha!! just figured out why your's wasn't working. I didn't see you changed the dcl path location hehe! Now it works. Thanks alot ill let you know how the erst of the code goes
 
Cheers !

CadFrank 发表于 2022-7-5 20:42:29

 
I've added the rest of the list and it still only show's the last radio list. If I select any of the other it won't display them.
 
it's like the other lists don't stay stored or something like that.
页: [1] 2
查看完整版本: DCL - Popup_list