slimpickinz Posted May 1, 2010 Posted May 1, 2010 I am attempting to create a dialog where if you select one option in a drop down list, other options in other lists are disabled. I have looked high and low for a simplified version of this, to no avail. Any suggestions? I will post my basic files directly for more clarity. -Slimp Quote
Lee Mac Posted May 1, 2010 Posted May 1, 2010 Hi Slim, I would suggest including functions to change your other lists within the action_tile statments of the list in question I shall provide an example if necessary Lee Quote
slimpickinz Posted May 1, 2010 Author Posted May 1, 2010 Hey Lee. Yeah please do. Here is what I got so far... (see attached.) ;///////////// 05-01-2010 \\\\\\\\\\\\\\\\\ ;//////////// Drawing Generator\\\\\\\\\\\\\\\\\ ;;AUTOLISP CODING STARTS HERE *** ASSOCIATED DCL FILE <DG.DCL**** (defun c:dg (/ Dcl_Id% NAMES$ NAMESQ$ ) (setq DGVersion "DG v1.0") ; this is the DCL title string (vl-cmdf "-layer" "ON" "*" "") ; turn on all layers to begin ;; This is the Master List for DCL variables ;; VarName TileName DefValue TileType listAssoc (setq MasterList '( (Q1 "Q1" 0 0 NAMESQ) (Q2 "Q2" 0 0 NAMESQ) (Q3 "Q3" 0 0 NAMESQ) )) ;; TileType 0 = PopUp_List ;; 1 = Toggle ;; ;; ********************* Start of get_data function *********************** ;; ;; Compressor Count, Subcooling & Liquid Injection Options ;; (defun get_data () (foreach itm MasterList (set (car itm) (get_tile (eval (cadr itm)))) ) ) ; defun get_data (defun Q(cnt) (setq cnt (atoi cnt)) (mode_tile "Q1" (if (> cnt 0) 0 1)) (mode_tile "Q2" (if (> cnt 0) 0 1)) (mode_tile "Q3" (if (> cnt 0) 0 1)) ) ;; ///////////////////// End of get_data function \\\\\\\\\\\\\\\\\\\\\\\\\ ;; ********************* Start of Pull Down List Define Section *********************** (setq NAMESQ '("None" "One" "Two" "Three" "Four" "Five")) ;; ;; ///////////////////// End of Pull Down List Define Section \\\\\\\\\\\\\\\\\\\\\\\\\ ;; ;; Locate DCL file & prepare to start it (setq dcl_id (load_dialog "DG.dcl")) ;load dialog (if (not (new_dialog "DG" dcl_id)) ;test for dialog (exit) ;exit if no dialog ) ;End if ;; ;; ********************* Start of List Box Build Section *********************** ;; (defun AddList (tile lst) (start_list tile) (mapcar 'add_list lst) (end_list) ) (foreach itm MasterList (if (zerop (cadddr itm)) (AddList (eval (cadr itm)) (eval (last itm))) ; debug CAB ) ) ;;=============================================================== (cond (*DGGlobal* ; recover last used settings (foreach itm MasterList (if (setq value (cdr (assoc (car itm) *DGGlobal*))) (set (car itm) value) ) ) ) (t ; set to default values (foreach itm MasterList (set (car itm) (itoa(caddr itm))) ) ) ) (Q Q1) ;;; (CompQtyS compqty2) ;; ///////////////////// End of List Box Build Section \\\\\\\\\\\\\\\\\\\\\\\\\ ;; Set all tiles (foreach itm MasterList (set_tile (cadr itm) (eval (car itm))) ) (set_tile "title" DGVersion) ; add title to DCL ;; ///////////////////// Begin Button Actions Definitions \\\\\\\\\\\\\\\\\\\\\\\\\ (action_tile "Q1" "(Q $value)") ;;; (action_tile "Q2" "(CompQtyS $value)") (action_tile "help" "(help \"acet-help\")") (action_tile "accept" "(get_data) (done_dialog) (setq userclick T)") ;action tile (action_tile "cancel" "(done_dialog) (setq userclick nil)") ;close dialog (start_dialog) (unload_dialog dcl_id) ;; ///////////////////// End of Button Actions Definitions \\\\\\\\\\\\\\\\\\\\\\\\\ ;; ************************************************************************************** ;; This Starts the Program to start processing the Data Selected from the Dialog Screen (if userclick (progn (setq Qcnt1 (atoi Q1)) ;;; compcnt2 (atoi Q2)) ;; set Global var & set local vars to strings from list (setq *DGGlobal* nil) (foreach itm MasterList (setq *DGGlobal* (cons (cons (car itm) (eval(car itm))) *DGGlobal*)) (set (car itm) (nth (atoi (eval(car itm))) (eval (last itm)))) ) ;; ///////////////////// End Read & Set of List Varibles Section \\\\\\\\\\\\\\\\\\\\\\\\\ ;; ///////////////////// Start command print of Varible Section \\\\\\\\\\\\\\\\\\\\\\\\\ ;;see other file named "princ.lsp" ;; ///////////////////// End of command print of Varible Section \\\\\\\\\\\\\\\\\\\\\\\\\ ;; This Ends the Program to start processing the Data Selected from the Dialog Screen ;; ///////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ;; (setvar "CMDECHO" 0) ; Set Autocad setvar " CMDECHO" to 0 to stop process of info scrolling in Autocad, Makes it run faster (command "_.undo" "_begin") ;; Set layers & catch any errors (defun SetLayer (status layname / err ) (setq err (vl-catch-all-apply 'vl-cmdf (list "-layer" status layname ""))) (if (vl-catch-all-error-p err) ; yes, error (princ (strcat "\n" (vl-catch-all-error-message err) "\n" layname)) ) ) ;; ///////////////// Begin Layer Controls ///////////////// (cond ((= Q1 "None") (SetLayer "off" "test*") ; All off ;;; (SetLayer "OFF" "test-[12345]") ;[...] Matches any one of the characters enclosed ) ((= Q1 "One") (SetLayer "ON" "test") ) ((= Q1 "Two") (SetLayer "on" "test2") ) ((= Q1 "Three") (SetLayer "on" "test3") ) ((= Q1 "Four") (SetLayer "on" "test4") ) ((= Q1 "Five") (SetLayer "ON" "test5") ) ) (command "_.undo" "_end") ) ) ; endif userclick ;; ;;This is where you need to Re-Set the " setvar " or Autocad will continue to run under those settings. ;; ;; Here the ' setvar "CMDECHO" ' is set back to a Value of " 1 " so the AutoCad command prompt will display commands. ;; This must be done before the program ends and clears itself. ;; (setq Layers nil MasterList nil) (setvar "CMDECHO" 1) (princ "\nType \"DG\" to start ") ) (princ) ;; ;;AUTOLISP CODING ENDS HERE ;; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> AUTOLISP CODING ENDS HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Where do I set the "Question 1" to be available for selection by default? I want to set it to none, with Questions 2 & 3 unavailable for selection. Thanks! test1.dwg DG.DCL DG.LSP Quote
Lee Mac Posted May 2, 2010 Posted May 2, 2010 An example for you to mull over Save DCL to Search Path, type "test" to invoke. Example.lsp Example.dcl Quote
slimpickinz Posted May 10, 2010 Author Posted May 10, 2010 ok... was working with this and adding other values... It keeps crashing... Reloaded your original, & when selecting Ferrari, and when attempting to select another model I am getting errors. (** Error: bad argument type: consp nil **) All other variations seem to work just fine. Looked it over several times, but cannot see what is wrong..... Please advise. Thanks~! Quote
Lee Mac Posted May 10, 2010 Posted May 10, 2010 Ah yes, that was picked up in another recent thread. see here - it uses list_boxes, but just replace the list_box definition with a popup_list and all will be the same. Quote
slimpickinz Posted May 10, 2010 Author Posted May 10, 2010 I really like the list boxes much better. Now I am having trouble adding 2 more list_boxes for my selections... Let's call them "color" and "condition" A little shove will be appreciated. :wink: Quote
Lee Mac Posted May 11, 2010 Posted May 11, 2010 I'm sure you can work from what I have provided Quote
slimpickinz Posted May 12, 2010 Author Posted May 12, 2010 Would you mind commenting this out a bit so I can get a better understanding of what is going on here. Not real clear, I am quite new at this. Thanks... -SlimP Quote
slimpickinz Posted May 17, 2010 Author Posted May 17, 2010 I have worked on this for hours, and cannot get the hang of it... Attached is a version I am trying to get to work. When I replace "Make" with "System" it loads and gets no errors, but the list box for System does not populate! Please take a look and see what I am doing wrong.. Thanks -SlimP Example-system.lsp Example.dcl Quote
The Buzzard Posted May 17, 2010 Posted May 17, 2010 I have worked on this for hours, and cannot get the hang of it...Attached is a version I am trying to get to work. When I replace "Make" with "System" it loads and gets no errors, but the list box for System does not populate! Please take a look and see what I am doing wrong.. Thanks -SlimP Thats odd because it is populated for me. I did not have to do anything to it. Sometimes you should close down acad and start up again and reload the program. Quote
The Buzzard Posted May 17, 2010 Posted May 17, 2010 I did find this however: The red "e" on the end of system in the alert. (alert (strcat "You have Selected - " system[color="Red"]e[/color] " " Model " " Year)) Quote
slimpickinz Posted May 17, 2010 Author Posted May 17, 2010 ok. this morning it worked. I swore I did what you suggested... Thanks for looking. Quote
The Buzzard Posted May 17, 2010 Posted May 17, 2010 ok. this morning it worked.I swore I did what you suggested... Thanks for looking. I know the feeling, I go thru it all the time. Sometimes you just got to give it a break. Anyway, Great to hear. Good Luck Quote
slimpickinz Posted May 20, 2010 Author Posted May 20, 2010 Having trouble understanding adding selections from the list_boxes... Not quite have the hang of it yet. Can you give me a hand here? I think you can see what I am trying to do. -Slimp Example-system2.lsp Example.dcl Quote
manddarran Posted May 20, 2010 Posted May 20, 2010 An example for you to mull over Save DCL to Search Path, type "test" to invoke. I have a 1988 Porsche 928 S4 :-).... I never thought of doing this, I have several ideas that this will be useful Quote
Lee Mac Posted May 20, 2010 Posted May 20, 2010 Hehe - I couldn't think of a better example at the time... Bear in mind that I linked to the updated code Quote
slimpickinz Posted May 21, 2010 Author Posted May 21, 2010 I have a 1988 Porsche 928 S4 :-).... I never thought of doing this, I have several ideas that this will be useful Still looking for a bit of assistance here guys... Quote
slimpickinz Posted June 3, 2010 Author Posted June 3, 2010 I would be willing to compensate someone to help finish this up.... Quote
Recommended Posts
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.