Make Popup List remember last selection

Make Popup List remember last selection

taitrongsong
Enthusiast Enthusiast
511 Views
8 Replies
Message 1 of 9

Make Popup List remember last selection

taitrongsong
Enthusiast
Enthusiast

I have an application to select paper size in autocad, how can I repeat the previous selection without having to re-select in the popup list. For example, initially I choose A3 paper size, then next time the popuplist will default to A3.

taitrongsong_0-1740917216784.png

 

0 Likes
512 Views
8 Replies
Replies (8)
Message 2 of 9

Moshe-A
Mentor
Mentor

@taitrongsong hi,

 

if you are talking about 3th party application then it is the application responsibility to create a defaults. in dialog box PLOT command, if you turn on Save Changes to layout or work with page setup you would get what you want.

 

Moshe

 

0 Likes
Message 3 of 9

taitrongsong
Enthusiast
Enthusiast

can you be more specific ? but this is a lisp application not a plot command

0 Likes
Message 4 of 9

paullimapa
Mentor
Mentor

Could you share the lisp file?

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor

@taitrongsong 

1. save the selected value of the popup_list tile as global variable, having got by get_tile.

2. load this value into the popup_list tile each time it's called by set_tile.

0 Likes
Message 6 of 9

Sea-Haven
Mentor
Mentor

You can save to the dwg a value so if you close and reopen the dwg you can retrieve the last value. You use LDATA.

 

(vlax-ldata-put "AlanH" "Listboxnum" num)

(setq num (vlax-ldata-get "AlanH" "Listboxnum")

(set_tile "list" "0") ; note 0 is 1st item in list
(set_tile "list" (rtos num 2 0)) ; should work not tested.
0 Likes
Message 7 of 9

scot-65
Advisor
Advisor

@taitrongsong 

 

Is the "remember from last time" a current session value or a DWG file value?

 

Session value = "gremlin". Declare in the top part of the section of code that begins with (new_dialog ...) and ends with (start_dialog).

 

(or USER_MyProgram (setq USER_MyProgram "3"))

 

For the DWG file value, employ sea-haven's method.

 

Now set the tile:

(set_tile "Lis01" USER_MyProgram)

 

For both methods, in the action_tile that will close the dialog, interrupt the closing action by recording the value.

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

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 8 of 9

taitrongsong
Enthusiast
Enthusiast

Hi scot -65

this is my DCL and LISP file, can you help me solve it.

0 Likes
Message 9 of 9

Moshe-A
Mentor
Mentor

@taitrongsong hi,

 

check this fix, no change in dcl

 

in dcl (dialog control language) list tile, the first item is "0", most tiles values is in string

you can not use (get_tile) function until the dialog is really open at (start_dialog) call.

of course you can not call (get_tile) after the dialog is closed (done_dialog)

 

to save list default selection, you need to save the item index to some global variable or write it to registry.

in my example i use sysvar USERI1 (this one will be reset when you close the document)

 

enjoy

Moshe

 

(defun c:smp (/ get_media ctrl_selection_1 ctrl_accept ; local functions
	        dclfname dcl_id deviceList what_next media^ defSel) 

 (defun get_media (i lst / dev)
  (setq dev (nth i lst))
  (cdr (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\control\\Print\\Printers\\" dev "\\DsDriver")"printMediaSupported"))
 )


 ; callback 
 (defun ctrl_selections_1 (/ iSel lst)
  (setq iSel (atoi (get_tile "selections_1")))
  (setq lst (get_media iSel deviceList))
  
  (start_list "selections_3")
  (mapcar 'add_list lst)
  (end_list)
  (set_tile "selections_3" "0")
 )
  
 ; callback
 (defun ctrl_accept ()
  ; (print_1)

  (setq defSel (setvar "useri1" (atoi (get_tile "selections_1"))))
  
  (done_dialog 1)
 )

  
 (setq defSel (getvar "useri1"))
  
 (if (and
       (setq dclfname (findfile "Tip1756k.dcl")) ; get dcl file from supprt files search path
       (setq dcl_id (load_dialog dclfname))	 ; get dcl id
     )
  (progn
   (setq deviceList (setq Path "\\System\\CurrentControlSet\\control\\Print\\" Printers (vl-registry-descendents (strcat "HKEY_LOCAL_MACHINE" Path "Printers"))))
  
   (setq what_next 2)
  
   (while (> what_next 1)
    (if (not (new_dialog "FormPrinter" dcl_id "" '(-1 -1))) ; open dialog
     (exit)
    )

    (start_list "selections_1")
    (mapcar 'add_list deviceList)
    (end_list)
    (set_tile "selections_1" (itoa defSel))
   
    (setq media^ (get_media defSel deviceList))
   
    (start_list "selections_3")
    (mapcar 'add_list media^)
    (end_list)
    (set_tile "selections_3" "0")

    (action_tile "selections_1" "(ctrl_selections_1)")
    ; (setq KV (getvar "ctab"))
    (action_tile "accept" "(ctrl_accept)")
     
    (setq what_next (start_dialog))

   ); while
  );progn
 ); if

 
 (unload_dialog dcl_id)

 (princ)
)

 

 

 

0 Likes