Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Dynamic User Input with Getstring List?

  1. #11
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    It seems I need to kind of "reset" the initget code each time it goes through the while loop, so I added this and it seems to work:
    Code:
     (prompt "\nNothing Entered or Not 3 Characters")
    	(initget 128 TypStr) ; in addition to the original one at the beginning
    	  (setq str nil)

  2. #12
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    Why not a dcl list to select from this one is from Alan J Thompson the calling code is
    (if (not AT:listselect )(load "listselect"))
    (AT:ListSelect title label height width multi lst)
    the lst being just that your list to pick from, just check the answer returned for say "ADD" then add to lst and rerun again.

    Code:
      ;; 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
        )
      )
    )

  3. #13
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    Easiest way is to use DOSLib -- dos_listbox
    http://www.en.na.mcneel.com/doslib/index.html
    Example:
    dos_listbox.jpg
    Code:
    Command: (dos_listbox "Set Current Layer" "Select a layer" '("Layer1" "Layer2" "Layer3"))
    "Layer1"

  4. #14
    Member Jim_Fisher's Avatar
    Join Date
    2015-12
    Location
    Texas
    Posts
    31
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    That's a good suggestion truevis (DOSLib is a great tool ), but doesn't meet the requirement of allowing the user to add to the list ...

  5. #15
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    Quote Originally Posted by Jim_Fisher View Post
    That's a good suggestion truevis (DOSLib is a great tool ), but doesn't meet the requirement of allowing the user to add to the list ...
    Then I'd use dos_editlist

    dos_combolist

    or one of their other functions -- just so easy!

  6. #16
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Dynamic User Input with Getstring List?

    I ended up with this, which works very well. Thanks for the help everyone

    Code:
      (defun _implode	(data delim / str n)
      ;; Join list items into string with delimiter string
      (if (and (= (type data) 'LIST)
    	   (= (type delim) 'STR)
    	   (> (strlen delim) 0)
          )
        (foreach n data
          (if str
    	(setq str (strcat str delim n))
    	(setq str n)
          )
        )
      )
    )
    
      ; SET DEFAULT TYPE LIST
      (setq *TypLst (list
    		 "PNL"
    		 "CAB"
    		 "DSK"
    		 "CLT"
    		 "TFS"
    		 "STD"
    		 "SGN"
    		 "DOR"
    		 "CLG"
    		 "FAS"
    		 "PST"
    		 "SUP"
    		 "MIS"
    		 )
    	)
      
      ; ADD ANY OTHERS TO THE OPTION LIST IF NOT ALREADY PRESENT
      (if (setq bss (ssget "x" (list '(0 . "INSERT") (cons 2 "@@@-#*,@@@-##*,@@@-###*"))))
        (progn
          (setq i 0)
          	(repeat (sslength bss)
    	  (setq en (ssname bss i))
         	  (setq blocktype (substr (_EFName en) 1 3))
    	    (if
        		(not (member blocktype *TypLst))
        		(setq *TypLst (cons blocktype *TypLst))
        		)
    	  (setq i (+ i 1))
    	  )
        )
      )
    
      ; SORT THE LIST
      (setq *TypLst (acad_strlsort *TypLst))
    
      ; BREAK THE LIST UP INTO A STRING WITH SPACES
    
    (setq TypStr (_implode *TypLst " "))
    
      ; ON FIRST RUN, SET DEFAULT OPTION
      
    (if (not *Typ) (setq *Typ (car *TypLst)))
    
      ; GET TYPE FROM USER
    
    (initget 128 TypStr)
      
    	(while
    	    (and
    	      (setq
    		str1 (getkword
    			       (strcat "\nChoose ["
    				       (vl-string-translate " " "/" TypStr)
    				       "] <"
    				       *Typ
    				       ">: "
    			       )
    			     )
    	      )
    		(/= str1 nil)
    	        (/= (strlen str1) 3)
    	    )
    	  (prompt "\nNot 3 Characters")
    	  (initget 128 TypStr)
    	  (setq str1 nil)
    	)
      
    (if
      (eq str1 nil)
       (setq str1 (strcase *Typ))
       (setq *Typ (strcase str1))
    )
    
      (princ *Typ)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2014: New Keynote/Tag User - Can User input be added.
    By jason.miller681034 in forum Revit - Platform
    Replies: 1
    Last Post: 2014-11-26, 05:13 PM
  2. Controlling visibility by user input method. (Not by the list.)
    By Ykang.236078 in forum Dynamic Blocks - Technical
    Replies: 3
    Last Post: 2010-11-23, 02:10 PM
  3. Anyone know how to get (getstring T) to work?
    By RapidCAD in forum AutoLISP
    Replies: 4
    Last Post: 2007-11-07, 06:02 PM
  4. Replies: 5
    Last Post: 2007-05-08, 09:59 PM
  5. Input bearings when using dynamic input
    By rmk in forum AutoCAD General
    Replies: 3
    Last Post: 2006-03-13, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •