Jump to content

Recommended Posts

Posted

I'm trying to get the set_tile command place a specific value into a tile depending on (something). So if (something) exists, then when the menu starts, the "nth whatever" of the list will be displayed, but still allow the user to select something different.

 

For some reason, it's not showing in the dropdown list tile. It still works if I select something, but the set_tile just doesn't seem to be working?

 

Thanks!

 

-ArgV

Posted

please post the file

are you calling set_tile after you populate the list?

Posted
please post the file

are you calling set_tile after you populate the list?

 

 

Yes, and the file is pretty large. I know I'm doing everything "right" because the lists are showing up, it just doesn't show up anything when I try to use set_tile. I don't know if it's even possible to use that to display a value. The other way would be to re-order the list depending on the found element so that it is first, and therefore would show up. ..

Posted

Hi,

 

If you want to display a value countained in the list, you have to pass set_tile the position of this value in the list as a string.

To display the 4th element : (set_tile "my_popup" "4")

 

You can have a look at this little example which allow to choose a layer in the drawing layer list (sorted). The popup displays the current layer.

 

(defun getlayer (/ lay lst tmp file dcl_id name)
 (while (setq lay (tblnext "LAYER" (not lay)))
   (setq lst (cons (cdr (assoc 2 lay)) lst))
   )
  (setq lst (vl-sort lst '<)
        tmp (vl-filename-mktemp "tmp.dcl")
        file (open tmp "w")
        )
 (write-line
   "getlayer:dialog{
   label=\"Choose a layer\";
   :popup_list{
   key=\"lay\";
   edit_width=25;}
   spacer;
   ok_cancel;}"
   file
 )
 (close file)
 (setq dcl_id (load_dialog tmp))
 (if (new_dialog "getlayer" dcl_id)
   (progn
     (start_list "lay")
     (mapcar 'add_list lst)
     (end_list)
     (set_tile "lay" (itoa (vl-position (getvar "CLAYER") lst)))
     (action_tile
       "accept"
       "(setq name (nth (atoi (get_tile \"lay\")) lst)) (done_dialog)"
     )
     (start_dialog)
     (unload_dialog dcl_id)
     (vl-file-delete tmp)
     name
     )
   )
 )

Posted
Hi,

 

If you want to display a value countained in the list, you have to pass set_tile the position of this value in the list as a string.

To display the 4th element : (set_tile "my_popup" "4")

 

You can have a look at this little example which allow to choose a layer in the drawing layer list (sorted). The popup displays the current layer.

 

(defun getlayer (/ lay lst tmp file dcl_id name)
 (while (setq lay (tblnext "LAYER" (not lay)))
   (setq lst (cons (cdr (assoc 2 lay)) lst))
   )
  (setq lst (vl-sort lst '<)
        tmp (vl-filename-mktemp "tmp.dcl")
        file (open tmp "w")
        )
 (write-line
   "getlayer:dialog{
   label=\"Choose a layer\";
   :popup_list{
   key=\"lay\";
   edit_width=25;}
   spacer;
   ok_cancel;}"
   file
 )
 (close file)
 (setq dcl_id (load_dialog tmp))
 (if (new_dialog "getlayer" dcl_id)
   (progn
     (start_list "lay")
     (mapcar 'add_list lst)
     (end_list)
     (set_tile "lay" (itoa (vl-position (getvar "CLAYER") lst)))
     (action_tile
       "accept"
       "(setq name (nth (atoi (get_tile \"lay\")) lst)) (done_dialog)"
     )
     (start_dialog)
     (unload_dialog dcl_id)
     (vl-file-delete tmp)
     name
     )
   )
 )

 

Hey thanks Gile. I swear I tried that, except using the "nth" command and it didn't work. Probably I did something dumb. Anyways, I like your code better.

 

thanks!

 

-ArgV

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...