Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/24/2024 in all areas

  1. niet compleet maar probeer deze maar eens... ;;; This program demonstrates how to update a secondary list_box based on user selection from a primary list_box. ;;; Example courtesy of Lee Mac © 2010 (www.lee-mac.com) (defun c:bout ( / *error* UpdateList data dclFileName dclFilePointer dclhandle *model* model *make* make selection) ;;; Error Handler - will unload the dialog from memory should the user decide to hit Esc (defun *error* ( msg ) (if dclHandle (unload_dialog dclHandle)) (if dclFilePointer (close dclFilePointer)) (if (findfile dclFileName)(vl-file-delete dclFileName)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")(princ (strcat "\n** Error: " msg " **")))(princ)) ;;; This function updates the list_box associated with the specified key using the contents of the supplied lst (defun UpdateList ( key lst ) (start_list key)(mapcar 'add_list lst)(end_list)) ;;; Data used to Populate List_Boxes: (setq Data '( ("M4" ("25" "30" "40")) ("M5" ("30" "35" "40" "45" "50" "55" "60" "65" "70" "75" "80")) ("M6" ("30" "35" "40" "45" "50" "55" "60" "65" "70" "75" "80")) ("M8" ("35" "40" "45" "50" "55" "60" "65" "70" "75" "80" "90" "100" "110" "120" "140" "150" "160" "180" "200")) ("M10" ("45" "50" "55" "60" "65" "70" "75" "80" "90" "100" "110" "120" "140" "150" "160" "180" "200")) ("M12" ("45" "50" "55" "60" "65" "70" "75" "80" "100" "110" "120" "140" "150" "160" "180" "200")) ("M14" ("50" "55" "60" "65" "70" "75" "80" "100" "110" "120" "140" "150" "160" "180" "200")) ("M16" ("50" "55" "60" "65" "70" "75" "80" "100" "110" "120" "140" "150" "160" "180" "200")) ) ) ;;; setup dialog (create_bout_dialog) ;;; Start of Main Routine Lots of Error Trapping to make sure the Dialog Loads: (cond ((<= (setq dclHandle (load_dialog dclFileName)) 0) (princ "\n--> DCL File not Found.")) ((not (new_dialog "bout" dclHandle)) (setq dclHandle (unload_dialog dclHandle)) (princ "\n--> Dialog Definition not Found.")) ;;; Dialog Loaded Successfully. (t ;;; Set up some default selections, for the first-time running of the program. ;;; The variables *Make* & *Model* are intended to be global and hence will remember the user's last selections. (or *Make* (setq *Make* "0")) (or *Model* (setq *Model* "0")) ;;; Populate the List_Boxes: ;;; List_Box 'lst1' (UpdateList "lst1" (mapcar 'car Data)) (set_tile "lst1" *Make*) ;;; List_Box 'lst2' (UpdateList "lst2" (cadr (nth (atoi *Make*) Data))) (set_tile "lst2" *Model*) ;;; Action_tile Statements: ;;; These control what happens when the user interacts with a tile in the dialog. (action_tile "lst1" (strcat "(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq *Make* $value)) Data))))" "(setq *Model*" " (set_tile \"lst2\"" " (if (< (atoi *Model*) (length lst2)) *Model* \"0\")" " )" ")" ) ) ;;; Here, when the user selects an item from 'lst1', the UpdateList subfunction ;;; is fired to update the items in list_box 'lst2'. ;;; list_box 'lst2' is also set to the value of *Model* if the index is ;;; available for the selected item, ELSE THE FIRST ITEM IS SELECTED. ;;; Note that $VALUE IS A STRING containg the index of the item ;;; that the user has selected. (action_tile "lst2" "(setq *Model* $value)") ;;; Dialog setup, lets start it: (start_dialog) (setq dclHandle (unload_dialog dclHandle)) (if (findfile dclFileName)(vl-file-delete dclFileName)) ) ) ;;;----------------------------------------My work - it doesn't work!!------------------------------------------- (cond (( and (= lst1 "M4")(= lst2 "25"))(SETQ WTBSYB "DIN931-A0M04x025E")(WTBSB)) (( and (= lst1 "M4")(= lst2 "30"))(SETQ WTBSYB "DIN931-A0M04x030E")(WTBSB)) (( and (= lst1 "M4")(= lst2 "40"))(SETQ WTBSYB "DIN931-A0M04x040E")(WTBSB)) (( and (= lst1 "M5")(= lst2 "30"))(SETQ WTBSYB "DIN931-A0M04x030E")(WTBSB)) (( and (= lst1 "M5")(= lst2 "35"))(SETQ WTBSYB "DIN931-A0M04x035E")(WTBSB)) (( and (= lst1 "M5")(= lst2 "40"))(SETQ WTBSYB "DIN931-A0M04x040E")(WTBSB)) (t (alert (strcat "lst1 = " (vl-princ-to-string lst1) "\nlst2 = " (vl-princ-to-string lst2)))) ) (alert (strcat "*Model* = " (vl-princ-to-string *Model*) "\n*Make* = " (vl-princ-to-string *Make*))) ;;; retrieve Model & Make (setq selection (nth (atoi *Model*) Data)) (setq model (car selection)) (setq make (nth (atoi *Make*) (cadr selection))) (alert (strcat "Model = " (vl-princ-to-string model) "\nMake = " (vl-princ-to-string make))) (princ) ) (DEFUN WTBSB ( / Y ) (Setvar "Cmdecho" 0) ; (SETQ OLDLAYER (GETVAR "CLAYER")) ; (SETQ LAY (IF (NOT (TBLSEARCH "LAYER" "03_GEOMETRIE_050")) ; (COMMAND "LAYER" "M" "03_GEOMETRIE_050" "C" "7" "" "L" "CONTINUOUS" "" "")) ; ) ; (COMMAND "LAYER" "S" "03_GEOMETRIE_050" "") (SETQ Y (getpoint "\nGeef Invoegpunt : ")) (Command "-Insert" WTBSYB Y "" "" Pause) ; (SETVAR "CLAYER" OLDLAYER) (PRINC) ) ;;; create the dialog on run-time (defun create_bout_dialog () (if (and (setq dclFileName (vl-filename-mktemp "bout.dcl")) (setq dclFilePointer (open dclFileName "w"))) (mapcar '(lambda (x)(write-line x dclFilePointer)) (list "lbox : list_box {width=25;fixed_width=true;alignment=centered;}" "bout : dialog { label =\"bout\"; spacer;" ":column {" " :row {label = \"Materiaal :\" ;" ": radio_button {label=\"Gegalvaniseerd 8.8\";key=\"A0\";value=1;}" ": radio_button {label=\"RVS A2\"; key=\"A2\";}" ": radio_button {label=\"RVS A4\"; key=\"A4\";}" "}" ":spacer { width=1;}" ":row {label=\"Aanzicht :\";" ": radio_button {label=\"Zijaanzicht\";key=\"zijaanz\";value=1;}" ": radio_button {label=\"Doorsnede\";key=\"doorsn\";}" "}" ":spacer {width=1;}" ": row {" ": lbox {key=\"lst1\";label=\"Make\";}" ": lbox {key=\"lst2\";label=\"Model\";}" "}" "}" "ok_cancel;" "}" ) ) ) (if dclFilePointer (close dclFilePointer))(gc) ) (c:bout) ps disabled all messages , need to focus on my own challenges bout.lsp
    1 point
×
×
  • Create New...