patjeacad Posted August 23 Posted August 23 Good morning all, I use a file from LeeMac and i want to change it for my bolt library. I have the whole library with initget and it works. Now I want to upgrade to DCL. (looks better. easier to use) The DCL is how i want it, the lisp file is not finnished. The first problem is to get the information from the 2 listboxes. What i made doens't work at all. Can someone point me in the right direction? Both files are enclosed. bout.lsp bout.dcl Quote
Steven P Posted August 23 Posted August 23 Just a quick look and I might be wrong! The output from the DCL lists will be a number 1, 2, 3, 4 and so on corresponding to the list item you chose - it looks like you are searching for the displayed text for example M4, M5 and so on - I think these will need to be 1, 2, 3 or whatever corresponding to your data at the top of the LISP. Have a check do a (princ lst1) or something to see what the output is 1 Quote
patjeacad Posted August 23 Author Posted August 23 3 hours ago, Steven P said: Just a quick look and I might be wrong! The output from the DCL lists will be a number 1, 2, 3, 4 and so on corresponding to the list item you chose - it looks like you are searching for the displayed text for example M4, M5 and so on - I think these will need to be 1, 2, 3 or whatever corresponding to your data at the top of the LISP. Have a check do a (princ lst1) or something to see what the output is When i change it to "0" or only 0 there is no responce. The second (cond ...) function does not work. Quote
patjeacad Posted August 23 Author Posted August 23 1 minute ago, patjeacad said: When i change it to "0" or only 0 there is no responce. The second (cond ...) function does not work. when i use princ brfore the second (cond..) -> (princ lst1) (princ lst2) NIL NIL. So there is nothing. 1 Quote
Steven P Posted August 23 Posted August 23 maybe you need to define lst1 and lst2 as variables instead of DCL tags? Change this bit to below and leave the princes in as above see what happens? (action_tile "lst1" (setq lst1 (get_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\")" " )" ")" ) ) Quote
patjeacad Posted August 23 Author Posted August 23 When i use (princ lst2) This is what autocad says: Command: BOUT (30 35 40 45 50 55 60 65 70 75 80). It gives the whole list instead one of the list. Only (princ lst1) = nil nil. there is a fault in this lisp routine? I also used the original lisp en dcl. the same problem. Quote
Steven P Posted August 23 Posted August 23 I'll try to remember to have a look next week - weekend coming and CAD is going off in about 9 minutes.. not going to be enough time for me today Quote
mhupp Posted August 23 Posted August 23 (edited) ;; Note that $value is a string containg the index of the item ;; that the user has selected. Think your looking to change the following (action_tile "lst2" "(setq *Model* $value)") need to set both values since your using them to check in your cond statment (action_tile "lst1" "(setq M $value)") (action_tile "lst2" "(setq S $value)") Then your cond change to (cond ((and (= M "M4")(= S "25")) (SETQ WTBSYB "DIN931-A0M04x025E")) does this run after you close the dcl menu? Maybe set up a test to see values (t (prompt "Nothing Matching") (prompt (strcat "\nM Value: " M)) (prompt (strcat "\nS Value: " S)) ) -Edit Tho it could be returning like "3" and "7" if you pick M6 and 60 so you might have to do (Setq M (car (nth 3 Data)) (Setq S (nth 7 (nth 3 Data)) -edit I would also join your two lisps (since the 2nd one is small) and use local variables. or clear WTBSYB in the 2nd one to prevent false positives. Edited August 23 by mhupp Quote
BIGAL Posted August 24 Posted August 24 (edited) DYNAMIC BOLT.dwgThere are some lisp dclsamples out there that do what you want select a bolt dia and a Child dcl pops with the sizes. Something like this. Size is chosen. This is a Child dcl. It can have children also I believe. In a simpler way you can use Multi radio buttons it chooses the next radio button dcl to display. You dont need to worry about the dcl coding, its handled for you. An example, just make sure you save Multi radio button.lsp in a support directory. (DEFUN C;WOWTEST ( / ANS LEN ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "V" '("Choose a bolt" "M4" "M5" "M6" "M8" "M10" "M12" "M16" "M20" "M24"))) ; ans holds the button picked (SETQ M4 (list "Choose bolt LENGTH " "25" "30" "40")) ; M6 ; M8 (COND ((= ANS "M4")(SETQ LEN M4) ; m6 m8 etc ) (setq LENGTH (ATOI (ah:butts 1 "V" LEN)))) (PRINC) ) Something like this as a result. RLX is great at dcl's he may answer, I will look at adding a new multi radio buttons version that has a child dcl option so all occurs in one dcl like top image. Lastly pretty sure have seen bolts, screws, capheads, allen, fastners and so on in a dcl and does what you want and a lot more. Sorry can not provide any more info need to google. Ps here is a bolt as well. Multi radio buttons.lsp Multi radio buttons.lsp Edited August 24 by BIGAL Quote
patjeacad Posted August 24 Author Posted August 24 19 hours ago, Steven P said: maybe you need to define lst1 and lst2 as variables instead of DCL tags? Change this bit to below and leave the princes in as above see what happens? (action_tile "lst1" (setq lst1 (get_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\")" " )" ")" ) ) I changed the lisp text for your text. And I get the message: ** Error: too many arguments ** from autocad. Quote
patjeacad Posted August 24 Author Posted August 24 6 hours ago, BIGAL said: DYNAMIC BOLT.dwgThere are some lisp dclsamples out there that do what you want select a bolt dia and a Child dcl pops with the sizes. Something like this. Size is chosen. This is a Child dcl. It can have children also I believe. In a simpler way you can use Multi radio buttons it chooses the next radio button dcl to display. You dont need to worry about the dcl coding, its handled for you. An example, just make sure you save Multi radio button.lsp in a support directory. (DEFUN C;WOWTEST ( / ANS LEN ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "V" '("Choose a bolt" "M4" "M5" "M6" "M8" "M10" "M12" "M16" "M20" "M24"))) ; ans holds the button picked (SETQ M4 (list "Choose bolt LENGTH " "25" "30" "40")) ; M6 ; M8 (COND ((= ANS "M4")(SETQ LEN M4) ; m6 m8 etc ) (setq LENGTH (ATOI (ah:butts 1 "V" LEN)))) (PRINC) ) Something like this as a result. RLX is great at dcl's he may answer, I will look at adding a new multi radio buttons version that has a child dcl option so all occurs in one dcl like top image. Lastly pretty sure have seen bolts, screws, capheads, allen, fastners and so on in a dcl and does what you want and a lot more. Sorry can not provide any more info need to google. Ps here is a bolt as well. Multi radio buttons.lsp 2.73 kB · 42 downloads Multi radio buttons.lsp 2.73 kB · 42 downloads i like the button option but there are for some bolts to much lenght. A listbox is better to use. Quote
rlx Posted August 24 Posted August 24 (edited) 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 Edited August 25 by rlx added (untested) version that should be able to insert block 1 Quote
BIGAL Posted August 24 Posted August 24 It was ok for me. Yes its at about the limit. Ok you can use a cond after getting bolt dia, to set the blst and this will pop a list. (if (not AHlstbox)(load "Listbox-AH.lsp")) (setq blst (list "35" "40" "45" "50" "55" "60" "65" "70" "75" "80" "90" "100" "110" "120" "140" "150" "160" "180" "200" )) (setq blen (nth (ahlstbox "Pick a number" blst 20 10) blst)) Listbox-AH.lsp Quote
patjeacad Posted August 25 Author Posted August 25 9 hours ago, BIGAL said: It was ok for me. Yes its at about the limit. Ok you can use a cond after getting bolt dia, to set the blst and this will pop a list. (if (not AHlstbox)(load "Listbox-AH.lsp")) (setq blst (list "35" "40" "45" "50" "55" "60" "65" "70" "75" "80" "90" "100" "110" "120" "140" "150" "160" "180" "200" )) (setq blen (nth (ahlstbox "Pick a number" blst 20 10) blst)) Listbox-AH.lsp 1.28 kB · 1 download thank you bigal. this is for my a bit difficult. i"ll try to understand what you sent me. Quote
BIGAL Posted August 25 Posted August 25 Thats ok what RLX has sent you should meet your needs. 1 Quote
patjeacad Posted August 28 Author Posted August 28 On 8/24/2024 at 8:03 PM, rlx said: 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 7.23 kB · 1 download (create_bout_dialog) is twice in this lisp. do i have to repalce it with your (create_bout_dialog)? Quote
rlx Posted August 28 Posted August 28 the code in the first part is just to show where you went wrong (lst1 is not a list but the key name of your listbox). That's why it always returns nil. The attached lisp file is all you need. You still have to implement the other sizes but it's a start for you to built on further. instead of creating a cond function for all combinations I used something like : ((eq model "M4")(setq WTBSYB (strcat "DIN931-A0M04x" (3ZFill make) "E")) (WTBSB)) Model "M4" = "DIN931-A0M04x" + make "E" but make is "25" so I use 3ZFill (3 Zero Fill) to turn it into "025" so symbol name becomes : "DIN931-A0M04x025E" Maybe "M5" = "DIN931-A0M05x" + make + "E" and "M6" = "DIN931-A0M06x" + make + "E" etc. This saves you a lot of extra code good luck! Quote
patjeacad Posted August 29 Author Posted August 29 19 hours ago, rlx said: the code in the first part is just to show where you went wrong (lst1 is not a list but the key name of your listbox). That's why it always returns nil. The attached lisp file is all you need. You still have to implement the other sizes but it's a start for you to built on further. instead of creating a cond function for all combinations I used something like : ((eq model "M4")(setq WTBSYB (strcat "DIN931-A0M04x" (3ZFill make) "E")) (WTBSB)) Model "M4" = "DIN931-A0M04x" + make "E" but make is "25" so I use 3ZFill (3 Zero Fill) to turn it into "025" so symbol name becomes : "DIN931-A0M04x025E" Maybe "M5" = "DIN931-A0M05x" + make + "E" and "M6" = "DIN931-A0M06x" + make + "E" etc. This saves you a lot of extra code good luck! thanks RLX, i give it a try. Quote
patjeacad Posted September 10 Author Posted September 10 Hi RLX, you helped my a lot with your adjustments to the lisp file. There is only one problem. When i use M5-70 or M6-70 or M16- 100; i get an error code: Bad argument type: consp nil. All the compositions work except for the second list above the 8th choice. than i get the error. The list is to long. regards, patrick bout.lsp Quote
rlx Posted September 10 Posted September 10 (edited) can't fully test app without the blocks but try it now. Only changed a few variable names so maybe working of program is a little clearer. Also added a few extra princs for debug info. Those can be removed once app runs as expected. (defun c:bout ( / *error* UpdateList data dcl-fn dcl-fp dcl-id drv M-pointer model S-pointer size selection) (defun *error* ( msg ) (if dcl-id (unload_dialog dcl-id)) (if dcl-fp (close dcl-fp)) (if (findfile dcl-fn)(vl-file-delete dcl-fn)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")(princ (strcat "\n** Error: " msg " **")))(princ) ) (defun UpdateList ( key lst ) (start_list key)(mapcar 'add_list lst)(end_list)) ;;; 3-zero fill (so "25" becomes "025") (defun 3ZFill (s) (while (> 3 (strlen s))(setq s (strcat "0" s))) s) (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) (cond ((<= (setq dcl-id (load_dialog dcl-fn)) 0) (princ "\n--> DCL File not Found.")) ((not (new_dialog "bout" dcl-id)) (setq dcl-id (unload_dialog dcl-id)) (princ "\n--> Dialog Definition not Found.")) (t (or M-pointer (setq M-pointer "0")) (or S-pointer (setq S-pointer "0")) (UpdateList "lst1" (mapcar 'car Data)) (set_tile "lst1" M-pointer) (UpdateList "lst2" (cadr (nth (atoi S-pointer) Data))) (set_tile "lst2" S-pointer) (action_tile "lst1" (strcat "(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq M-pointer $value)) Data))))" "(setq S-pointer" " (set_tile \"lst2\"" " (if (< (atoi S-pointer) (length lst2)) S-pointer \"0\")" " )" ")" ) ) (action_tile "lst2" "(setq S-pointer $value)") (action_tile "cancel" "(done_dialog 0)") (action_tile "accept" "(done_dialog 1)") (setq drv (start_dialog)) (setq dcl-id (unload_dialog dcl-id)) (if (findfile dcl-fn)(vl-file-delete dcl-fn)) ) ) (if (= drv 1) (progn (setq selection (nth (atoi M-pointer) Data)) ;;; testing only (princ (strcat "\nSelection : " (vl-princ-to-string selection) "\nM-pointer : " (vl-princ-to-string M-pointer) " S-ppointer : " (vl-princ-to-string S-pointer))) (setq model (car selection)) (setq size (nth (atoi M-pointer) (cadr selection))) (cond ((eq model "M4") (setq WTBSYB (strcat "DIN931-A0M04x" (3ZFill size) "E")) (WTBSB)) ((eq model "M5") (setq WTBSYB (strcat "DIN931-A0M05x" (3ZFill size) "E")) (WTBSB)) ((eq model "M6") (setq WTBSYB (strcat "DIN931-A0M06x" (3ZFill size) "E")) (WTBSB)) ((eq model "M8") (setq WTBSYB (strcat "DIN931-A0M08x" (3ZFill size) "E")) (WTBSB)) ((eq model "M10")(setq WTBSYB (strcat "DIN931-A0M10x" (3ZFill size) "E")) (WTBSB)) ((eq model "M12")(setq WTBSYB (strcat "DIN931-A0M12x" (3ZFill size) "E")) (WTBSB)) ((eq model "M14")(setq WTBSYB (strcat "DIN931-A0M14x" (3ZFill size) "E")) (WTBSB)) ((eq model "M16")(setq WTBSYB (strcat "DIN931-A0M16x" (3ZFill size) "E")) (WTBSB)) (t (alert (strcat "Unknow combination :\nModel = " (vl-princ-to-string model) "\nsize = " (vl-princ-to-string size)))) ) ) ) (princ) ) (defun wtbsb ( / old-cmdecho old-layer ip ) (setq old-cmdecho (getvar "cmdecho")) (setvar "cmdecho" 0) (setq old-layer (getvar "clayer")) (if (not (tblsearch "layer" "03_geometrie_050")) (progn (command "layer" "m" "03_geometrie_050" "c" "7" "" "l" "continuous" "" "") (command "layer" "s" "03_geometrie_050" "") ) ) (cond ((or (null WTBSYB) (not (eq (type WTBSYB) 'STR)) (not (findfile (strcat WTBSYB ".dwg")))) (alert (strcat "Computer says no - bad or missing blockname : " (vl-princ-to-string WTBSYB)))) ((not (setq ip (getpoint "\nGeef invoegpunt : "))) (alert "Block insertion aborted")) (t (command "-insert" WTBSYB ip "" "" pause)) ) (setvar "clayer" old-layer) (setvar "cmdecho" old-cmdecho) (princ) ) ;;; create the dialog on run-time (defun create_bout_dialog () (if (and (setq dcl-fn (vl-filename-mktemp "bout.dcl")) (setq dcl-fp (open dcl-fn "w"))) (mapcar '(lambda (x)(write-line x dcl-fp)) (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=\"size\";}" ": lbox {key=\"lst2\";label=\"Model\";}" "}" "}" "ok_cancel;" "}" ) ) ) (if dcl-fp (close dcl-fp))(gc) ) Edited September 11 by rlx 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.