Jump to content

Recommended Posts

Posted

I'm trying to create a listbox with dcl, to be able to select multiple items. But I can't find any hint how to go about it, the only example I could find in autocad is this:

 

(defun selectItem( lstItems dcl-fileName dialogName / dcl_id LT lstLinkTemplates selectedItem)

 (setq dcl_id (load_dialog dcl-filename))      ; Load the DCL file 

 (if (not (new_dialog dialogName dcl_id))      ; Initialize the dialog 
     (progn
(princ (strcat "\n " dcl-filename " dialog not found.\n"))
(exit)                                   ; Exit if this doesn't work
     )
 )


 ;; Construct list of items
 (start_list "selections")                  ; Specify the name of the list box 
     (mapcar 'add_list lstItems)            ; Specify the AutoLISP list 
 (end_list)

 ;;
 ;;
 (defun getItemSelection()
   (setq selectedItem (nth (atoi $value) lstItems)  )
   (if (equal 4 $reason)		; Then user double-clicked item.
(done_dialog))
 )

 ;;
 ;; Confirms that user selected an item and that the item exists in list
 ;;
 (defun check_i()
   (if (member selectedItem lstItems)
     (progn 
       (set_tile "error" "") 
       T
     )
     (progn 
       (set_tile "error" "Please select an item.")
       nil
     )
   )
 )

  (action_tile "selections" "(getItemselection)")
 (action_tile "accept"     "(if (check_i)(done_dialog 1))")
 (action_tile "cancel"     "(setq selectedItem nil)(done_dialog 0)(exit)")


 (start_dialog)                             ; Display the dialog box 

 (unload_dialog dcl_id)                     ; Unload the DCL file 

 (princ "\n")

 selectedItem				; Return this value.
)

 

But as I understand this only allows one selection in the listbox, how can I allow multiple selections?

 

And what are the $value $reason variables, is there an explanation about this somewhere?

Posted

mutiple_select = true; :)

 

As for the $value etc, look at:

 

Working with Programmable Dialog Boxes > Managing Dialog Boxes > Action Expressions and Callbacks

 

In VLIDE help :)

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