How do I display a list of layers in a dcl list-box?

How do I display a list of layers in a dcl list-box?

Anonymous
Not applicable
2,532 Views
4 Replies
Message 1 of 5

How do I display a list of layers in a dcl list-box?

Anonymous
Not applicable

I have the list of layers ready but i'm not sure how to display it in my menu. Any help is appreciated.

0 Likes
Accepted solutions (1)
2,533 Views
4 Replies
Replies (4)
Message 2 of 5

rkmcswain
Mentor
Mentor
Accepted solution

The title of your post says "dcl list box", but the subject says "in my menu"?

Which one of these are you trying to do?

 

If the former, presuming you have a list of layers named 'laynames' and your list box control is named "lay", do it like this.

 

(start_list "lay")
(mapcar 'add_list laynames)
(end_list)

 

If you're looking for a ready made list box, ready for your list of layers, see this.

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 5

Anonymous
Not applicable

Sorry i meant in my list box.

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

This is the one I use by Alan Thompson

  ;; List Select Dialog (Temp DCL list box selection, based on provided list)
  ;; title - list box title
  ;; label - label for list box
  ;; height - height of box
  ;; width - width of box
  ;; multi - selection method ["true": multiple, "false": single]
  ;; lst - list of strings to place in list box
  ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite)
(defun AT:ListSelect (title label height width multi lst / fn fo d f)
  (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
  (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;")
                   (strcat ": list_box { label = \"" label "\";" "key = \"lst\";")
                   (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";")
                   (strcat "width = " (vl-princ-to-string width) ";")
                   (strcat "multiple_select = " multi "; } spacer; ok_cancel; }")
             )
    (write-line x fo)
  )
  (close fo)
  (new_dialog "list_select" (setq d (load_dialog fn)))
  (start_list "lst")
  (mapcar (function add_list) lst)
  (end_list)
  (setq item (set_tile "lst" "0"))
  (action_tile "lst" "(setq item $value)")
  (setq f (start_dialog))
  (unload_dialog d)
  (vl-file-delete fn)
  (if (= f 1)
    ((lambda (s / i s l)
       (while (setq i (vl-string-search " " s))
         (setq l (cons (nth (atoi (substr s 1 i)) lst) l))
         (setq s (substr s (+ 2 i)))
       )
       (reverse (cons (nth (atoi s) lst) l))
     )
      item
    )
  )
)
0 Likes
Message 5 of 5

Asocierea_Gur_Sim
Explorer
Explorer

Very nice. Thanks!

0 Likes