mhy3sx Posted April 12 Posted April 12 I am trying to learn DCL , how to insert block with a DCL slide menu. I have a folder with name north in C drive. Inside I have 4 slides with names NORTH1.sld,NORTH2.sld,NORTH3.sld,NORTH4.sld the north.dcl and the north.lsp I have a different lisp name symbols.lsp and call from this lisp (c:north1),(c:north2),(c:north3),(c:north4) nort : dialog { label = "North Dialog"; : row { : button { key = "north1"; label = "North 1"; is_default = true; action = "(c:north1)"; image = "C:\\North\\NORTH1.sld"; } : button { key = "north2"; label = "North 2"; action = "(c:north2)"; image = "C:\\North\\NORTH2.sld"; } } : row { : button { key = "north3"; label = "North 3"; action = "(c:north3)"; image = "C:\\North\\NORTH3.sld"; } : button { key = "north4"; label = "North 4"; action = "(c:north4)"; image = "C:\\North\\NORTH4.sld"; } } ok_cancel; } The lisp code (defun c:north () (load_dialog "C:\\north\\north.dcl") (if (not (new_dialog "north" 1)) (exit) ) (action_tile "button1" "(c:north1)") (action_tile "button2" "(c:north2)") (action_tile "button3" "(c:north3)") (action_tile "button4" "(c:north4)") (start_dialog) ) This code gives me this errors c:/north/north.dcl : line 9 : syntax error at "image" and when i hit ok c:/north/north.dcl : line 9 : syntax error at "=" I start learning DCL can anyone help ? Thanks Quote
pkenewell Posted April 12 Posted April 12 (edited) @mhy3sx You have the following issues: 1) the "Button" DCL tile cannot have an image, use "image_button" instead. 2) There is no "image" attribute for DCL. With the standard "image" tiles, you can use the "value" attribute, but NOT for "image_buttons". You will have to use (set_tile) at runtime. 3) You don't need to used both the "action" attribute and the (action_tile) calls. I recommend sticking to just using the (action_tile) calls. 4) You need to save the load dialog return value and then unload the dialog at the end. DCL: nort : dialog { label = "North Dialog"; : row { : image_button { key = "north1"; label = "North 1"; is_default = true; } : image_button { key = "north2"; label = "North 2"; } } : row { : image_button { key = "north3"; label = "North 3"; } : image_button { key = "north4"; label = "North 4"; } } ok_cancel; } AutoLISP: (defun c:north (/ dcl) (setq dcl (load_dialog "C:\\north\\north.dcl")) (if (not (new_dialog "north" dcl)) (exit) ) (set_tile "north1" "C:\\North\\NORTH1.sld") (set_tile "north2" "C:\\North\\NORTH2.sld") (set_tile "north3" "C:\\North\\NORTH3.sld") (set_tile "north4" "C:\\North\\NORTH4.sld") (action_tile "button1" "(c:north1)") (action_tile "button2" "(c:north2)") (action_tile "button3" "(c:north3)") (action_tile "button4" "(c:north4)") (start_dialog) (unload_dialog dcl) ) Edited April 12 by pkenewell 1 Quote
BIGAL Posted April 13 Posted April 13 Ignoring the maybe you want north point in 4 Directions ? You can get the North point to rotate to the twist angle of the mview in a layout with a lisp. So even if upside down arrow points in correct direction. Please confirm if this is what your after. Quote
mhy3sx Posted April 13 Author Posted April 13 (edited) Hi pkenewell. I text your code and gives me nil. No DCL menu open. I try to convert the code to this (defun c:north (/ *error* dch dcl des) (defun *error* ( msg ) (if (and (= 'int (type dch)) (< 0 dch)) (unload_dialog dch) ) (if (= 'file (type des)) (close des) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w") ) ) (princ "\nUnable to open DCL for writing.") ) ( (progn (foreach str '( "ed : edit_box" "{" " alignment = left;" " width = 200;" " edit_width = 200;" " fixed_width = true;" "}" "" "north : dialog" "{" " spacer;" " key = \"dcl\";" " : row" " {" " : image_button { key = \"north1\"; label = \"North 1:\"; is_default = true;}" " : image_button { key = \"north2\"; label = \"North 2:\"; }" " }" ;end row " : row" " {" " : image_button { key = \"north3\"; label = \"North 3:\";}" " : image_button { key = \"north4\"; label = \"North 4:\";}" " }" ;end row " : column { width = 17;" " : button { key = \"OK\"; label = \"OK\"; is_default = true;" " is_cancel = true; fixed_width = true; width = 10; }" " }" ; end column "}" ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ( (not (new_dialog "north" dch)) (princ "\nUnable to display 'north' dialog.") ) (t (set_tile "dcl" "North symbols") (set_tile "north1" "C:\\North\\NORTH1.sld") (set_tile "north2" "C:\\North\\NORTH2.sld") (set_tile "north3" "C:\\North\\NORTH3.sld") (set_tile "north4" "C:\\North\\NORTH4.sld") (action_tile "north1" "(c:north1)") (action_tile "north2" "(c:north2)") (action_tile "north3" "(c:north3)") (action_tile "north4" "(c:north4)") (start_dialog) ) ) (*error* nil) (princ) ); end defun Now the dcl menu open but is small and the sld is missing . I want to make something like test.jpg. How to update the code? Thanks Edited April 13 by mhy3sx Quote
mhy3sx Posted April 13 Author Posted April 13 Hi I update the code , works but I want to fix some bugs 1) When i select the north slide didn't mark (for example North 1) 2) If I select North 1 not insert first slide block 3) I want to add Previous and next Buttons (If I have mote blocks) 4) When I select one slide and press OK ot exit do nothing , I have to press the X button to close the DCL menu and then insert the block (defun c:north (/ f d id) (if (and (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w"))) (progn (write-line (strcat "north : dialog" "{" "label = \"North symbols\"; width = 42;" " : row" " {" ": list_box { key = \"l\"; width = 5;}" " : column" " {" " : image_button { key = \"north1\"; label = \"North 1:\"; height = 4; width = 4;}" " : image_button { key = \"north2\"; label = \"North 2:\"; height = 4; width = 4; }" " : image_button { key = \"north3\"; label = \"North 3:\"; height = 4; width = 4;}" " : image_button { key = \"north4\"; label = \"North 4:\"; height = 4; width = 4;}" " }" ;end column "}" ;end row ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;" ": button { label = \"Okay\"; key = \"ok\"; is_default = true; height = 1.75; width = 12;}" ": button { label = \"Exit\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 12;}" "}}" ) f ) (close f) ) (alert "Can't load the temporary file <!>") ) (if (or (not d) (> 0 (setq id (load_dialog d))) (not (new_dialog "north" id))) (progn (if (> id 0) (unload_dialog id) ) (if (and d (setq d (findfile d))) (vl-file-delete d) ) ) (progn (mapcar '(lambda (s k) (start_image k) (fill_image 0 0 (dimx_tile k) (dimy_tile k) 0) (slide_image 0 0 (dimx_tile k) (dimy_tile k) s) (end_image) ) (list "C:\\North\\NORTH1.sld" "C:\\North\\NORTH2.sld" "C:\\North\\NORTH3.sld" "C:\\North\\NORTH4.sld") (list "north1" "north2" "north3" "north4") ) (start_list "l") (mapcar 'add_list '("North 1" "North 2" "North 3" "North 4")) (end_list) (action_tile "north1" "(c:north1)") (action_tile "north2" "(c:north2)") (action_tile "north3" "(c:north3)") (action_tile "north4" "(c:north4)") (action_tile "ok" "(done_dialog)") (action_tile "esc" "(done_dialog)") (start_dialog) (unload_dialog id) ) ) (princ) ) Can any one help ? Thanks Quote
BIGAL Posted April 13 Posted April 13 (edited) If you want next & previous just use a pop menu its built in to CAD so easy to make as its part of say a custom mnu. Happy to provide some samples. This is a smaller dcl in the zip could have a 2x2 to suit your north points. DD4X3.zip Edited April 13 by BIGAL Quote
mhy3sx Posted April 14 Author Posted April 14 Hi Bigal. I alredy have image menus, but I am using ZWCAD now and in the new version ZWCAD 2025 ,Idon't know why they stop support image menus (not working). So I am trying to learn how to make a DCL slide menu as I want . Quote
mhy3sx Posted April 14 Author Posted April 14 I update the code but I can not insert the blocks. I want to select the slide and when I click OK to insert the selected block. The blocks calles from other lisp (c:north1),(c:north2),(c:north3),(c:north4) (defun c:north (/ f d id) (if (and (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w"))) (progn (write-line (strcat "north : dialog {" "label = \"North symbols\"; width = 42;" ": row {" ": list_box { key = \"l\"; width = 5;}" ": column {" ": image_button { key = \"north1\"; label = \"North 1:\"; height = 4; width = 4;}" ": image_button { key = \"north2\"; label = \"North 2:\"; height = 4; width = 4;}" ": image_button { key = \"north3\"; label = \"North 3:\"; height = 4; width = 4;}" ": image_button { key = \"north4\"; label = \"North 4:\"; height = 4; width = 4;}" "}" ;end column "}" ;end row ": column { width = 17;" ": button { key = \"OK\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 10; }" "}" ; end column "}" ) f ) (close f) ) (alert "Can't load the temporary file <!>") ) (if (or (not d) (> 0 (setq id (load_dialog d))) (not (new_dialog "north" id))) (progn (if (> id 0) (unload_dialog id) ) (if (and d (setq d (findfile d))) (vl-file-delete d) ) ) (progn (mapcar '(lambda (s k) (start_image k) (fill_image 0 0 (dimx_tile k) (dimy_tile k) 0) (slide_image 0 0 (dimx_tile k) (dimy_tile k) s) (end_image) ) (list "C:\\North\\NORTH1.sld" "C:\\North\\NORTH2.sld" "C:\\North\\NORTH3.sld" "C:\\North\\NORTH4.sld") (list "north1" "north2" "north3" "north4") ) (start_list "l") (mapcar 'add_list '("North 1" "North 2" "North 3" "North 4")) (end_list) (action_tile "north1" "(set_tile \"l\" \"0\")") (action_tile "north2" "(set_tile \"l\" \"1\")") (action_tile "north3" "(set_tile \"l\" \"2\")") (action_tile "north4" "(set_tile \"l\" \"3\")") (action_tile "OK" "(progn (done_dialog) (cond ((= (get_tile \"l\") \"0\") (c:north1)) ((= (get_tile \"l\") \"1\") (c:north2)) ((= (get_tile \"l\") \"2\") (c:north3)) ((= (get_tile \"l\") \"3\") (c:north4))))") (start_dialog) ) ) (princ) ) Quote
BIGAL Posted April 15 Posted April 15 I will see if I can pull out a 2x2 dcl for 4 slides, the dd3x4.dcl are buried away in a big program, but they are simply called by a repeat loop same with selection. You can make the call in 2 lines to use say a library lisp that contains all the 2x2 3x3 4x3 44 etc dcl's as a library lisp rather than have as code in each program. I Use RLX convert dcl to lisp worth getting a copy. I will try to find some time to do. Quote
pkenewell Posted April 15 Posted April 15 On 4/14/2024 at 6:04 AM, mhy3sx said: I update the code but I can not insert the blocks. @mhy3sx First - and most importantly, you cannot run any code that has a COMMAND sequence in it (i.e. "(Command "INSERT"...)" ) while the dialog is still active. You have to set the return to a variable and read it after the dialog closes. See below: (defun c:north (/ f d id) (if (and (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w"))) (progn (write-line (strcat "north : dialog {" "label = \"North symbols\"; width = 42;" ": row {" ": list_box { key = \"l\"; width = 5;}" ": column {" ": image_button { key = \"north1\"; label = \"North 1:\"; height = 4; width = 4;}" ": image_button { key = \"north2\"; label = \"North 2:\"; height = 4; width = 4;}" ": image_button { key = \"north3\"; label = \"North 3:\"; height = 4; width = 4;}" ": image_button { key = \"north4\"; label = \"North 4:\"; height = 4; width = 4;}" "}" ;end column "}" ;end row ": column { width = 17;" ": button { key = \"OK\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 10; }" "}" ; end column "}" ) f ) (close f) ) (alert "Can't load the temporary file <!>") ) (if (or (not d) (> 0 (setq id (load_dialog d))) (not (new_dialog "north" id))) (progn (if (> id 0) (unload_dialog id) ) (if (and d (setq d (findfile d))) (vl-file-delete d) ) ) (progn (mapcar '(lambda (s k) (start_image k) (fill_image 0 0 (dimx_tile k) (dimy_tile k) 0) (slide_image 0 0 (dimx_tile k) (dimy_tile k) s) (end_image) ) (list "C:\\North\\NORTH1.sld" "C:\\North\\NORTH2.sld" "C:\\North\\NORTH3.sld" "C:\\North\\NORTH4.sld") (list "north1" "north2" "north3" "north4") ) (start_list "l") (mapcar 'add_list '("North 1" "North 2" "North 3" "North 4")) (end_list) (action_tile "l" "(setq bk $value)") (action_tile "north1" "(set_tile \"l\" (setq bk \"0\"))") (action_tile "north2" "(set_tile \"l\" (setq bk \"1\"))") (action_tile "north3" "(set_tile \"l\" (setq bk \"2\"))") (action_tile "north4" "(set_tile \"l\" (setq bk \"3\"))") (action_tile "OK" "(done_dialog 1") (setq ret (start_dialog)) (unload_dialog id) (if (= ret 1) (cond ((= bk "0")(c:north1)) ((= bk "1")(c:north2)) ((= bk "2")(c:north3)) ((= bk "3")(c:north4)) ) ) ) ) (princ) ) Second: To do "Previous" and "Next" buttons, you will need to set a pointer for the max number of slides that can be displayed, then if the list if greater, you will need to read in the first part of the list into the slides and list box up to the pointer, then when the "Next" button is pressed. re-populate the list box and the slides, starting at the pointer up to the next pointer or the end of the list. You will also have to process the results different, instead of a bunch of separate LISP command calls like (c:north1), etc. you will have to make 1 function and feed it the correct number or item from the list. Something like (Insert_block "North1"). Sorry I don't have code for you. I suggest you supply your complete code, if you want better help. Quote
BIGAL Posted April 16 Posted April 16 In your other post about this I have given it some thought, and started doing a lisp with 2x2 3x2 3x4 4x4 all in one etc. But have decided to throw it away and write a global answer for select images. if you look at 4 6 9 12 16 represents a 2x2 3x2 3x3 4x3 4x4 dcls so just look at how many slides to be displayed so then have row=2 col=2 for a 2x2 dcl. You just do a cond (<= 4 will mean row=2 col=2. As the filling of the slides is a loop can have less than the max display value. So it would return which sq was picked, you can then use that to determine the next step. ;(defun sq_picked (ans / ) ; (cond ; ((= ans "sq1")(func1)) ; ((= ans "sq2")(func2)) ; ((= ans "sq3")(func3)) ; ((= ans "sq4")(func4)) ; ((= ans "sq5")(func5)) ; ((= ans "sq6")(func6)) ; ((= ans "sq7")(func7)) ; ((= ans "sq8")(func8)) ; ((= ans "sq9")(func9)) ; ) ;) in terms of coding it would be like 3 lines of code similar approach to the Multi lisp programs I have done. Any one comments before I get to carried away. Quote
BIGAL Posted April 16 Posted April 16 Ok had some time hopefully this works ok very limited testing. ; Calling example for make dcl XY slide images selected ; BY alan H April 2024 (defun c:wow ( / lst len ans) (setq lst (list "C:\\slides\\40km-School-Zone-Proposed" "C:\\slides\\40kph-Proposed.sld" "C:\\slides\\50kph-Proposed.sld" "C:\\slides\\60kph-Proposed.sld" "C:\\slides\\Bikeroad.sld" "C:\\slides\\dr_hwall_dissi.sld" "C:\\slides\\dr_pav_bend.sld" "C:\\slides\\dr_pav_pipe_con.sld" "C:\\slides\\dr_pav_pipe_conx.sld" ) ) (setq len (length lst)) (if (not makedclxy)(load "make dcl xy")) ; if you know how many dont need cond just do like (makedclxy lst 3 3) (cond ((<= len 4)(makedclxy lst 2 2)) ((<= len 6)(makedclxy lst 3 2)) ((<= len 9 len))(makedclxy lst 3 3)) ((<= len 12)(makedclxy lst 4 3)) ((<= len 16)(makedclxy lst 4 4)) ((> 16 len)(progn (alert "version 2") (exit))) ) ; do something here like insert a block (cond ((= ans "sq1")(alert "func1")) ((= ans "sq2")(alert "func2")) ((= ans "sq3")(alert "func3")) ((= ans "sq4")(alert "func4")) ((= ans "sq5")(alert "func5")) ((= ans "sq6")(alert "func6")) ((= ans "sq7")(alert "func7")) ((= ans "sq8")(alert "func8")) ((= ans "sq9")(alert "func9")) ) (princ) ) ; make a dcl of slide images and select one ; By AlanH Aptil 2024 (defun makedclxy (lst row col / ) (setq dcl (vl-filename-mktemp nil nil ".dcl") ) (setq fo (open dcl "w")) ; (setq fo (open "D:\\acadtemp\\test.dcl" "w") ) (setq x 0 imglst '()) (write-line (strcat "dd" (rtos row 2 0) "x" (rtos col 2 0) " : dialog {") fo) (write-line " label = \"Please choose \" ;" fo) (write-line " : column {" fo) (repeat col (write-line " : row {" fo) (repeat row (write-line " : image_button {" fo) (write-line (strcat " key = \"sq" (rtos (setq x (1+ x)) 2 0) "\" ;") fo) (setq imglst (cons (strcat "sq" (rtos x 2 0)) imglst)) (write-line " width = 10 ;" fo) (write-line " aspect_ratio = 1.0 ;" fo) c(write-line " color = 0 ;" fo) (write-line " allow_accept = true;" Fo) (write-line " }" fo) ) (write-line " }" fo) ) (write-line " }" fo) (write-line "ok_cancel ;" fo) (write-line "}" fo) (close fo) (setq imglst (reverse imglst)) (setq dcl_id (load_dialog "D:\\acadtemp\\test.dcl")) (if (not (new_dialog (strcat "dd" (rtos row 2 0) "x" (rtos col 2 0)) dcl_id)) (exit) ) (setq x -1) (foreach img imglst (setq sldname (nth (setq x (1+ x)) lst)) (start_image img) (slide_image 0 0 (- (dimx_tile img) 1) (- (dimy_tile img) 1) sldname) (end_image) ) (foreach sld imglst (action_tile sld "(done_dialog)(setq ans $key)") ) (action_tile "accept" "(done_dialog)") (start_dialog) (unload_dialog dcl_id) (princ ans) (princ) ) Quote
BIGAL Posted April 16 Posted April 16 Some good stuff on Terry's site, like the label on the image select dcl need to add that to what I did. Quote
BIGAL Posted April 18 Posted April 18 (edited) Version 2 the list that is passed has 2 items slide name and description. ; make a dcl of slide images and select one ; By AlanH April 2024 ; Calling example for make dcl XY slide images selected ; BY alan H April 2024 ; (defun c:wow ( / lst len ans) ; (setq lst (list ; (list "C:\\slides\\40km-School-Zone-Proposed" "40 school") ; (list "C:\\slides\\40kph-Proposed.sld" "40 Kph") ; (list "C:\\slides\\50kph-Proposed.sld" "50 Kph") ; (list "C:\\slides\\60kph-Proposed.sld" "60 Kph") ; (list "C:\\slides\\Bikeroad.sld" "Bike") ; (list "C:\\slides\\dr_hwall_dissi.sld" "Headwall") ; (list "C:\\slides\\dr_pav_bend.sld" "Bend") ; (list "C:\\slides\\dr_pav_pipe_con.sld" "Pipecon") ; (list "C:\\slides\\dr_pav_pipe_conx.sld" "Pipeconx") ; ) ; ) ; if you know how many dont need cond just do like (makedclxy lst 3 3) ;(setq len (length lst)) ; (if (not makedclxy)(load "make dcl xy")) ; if you know how many dont need cond just do like (makedclxy lst 3 3) ; (cond ; ((<= len 4)(makedclxy lst 2 2)) ; ((<= len 6)(makedclxy lst 3 2)) ; ((<= len 9)(makedclxy lst 3 3)) ; ((<= len 12)(makedclxy lst 4 3)) ; ((<= len 16)(makedclxy lst 4 4)) ; ((> 16 len)(progn (alert "version 2") (exit))) ; ) ; do something here like insert a block ; (cond ; ((= ans "sq1")(alert "func1")) ; ((= ans "sq2")(alert "func2")) ; ((= ans "sq3")(alert "func3")) ; ((= ans "sq4")(alert "func4")) ; ((= ans "sq5")(alert "func5")) ; ((= ans "sq6")(alert "func6")) ; ((= ans "sq7")(alert "func7")) ; ((= ans "sq8")(alert "func8")) ; ((= ans "sq9")(alert "func9")) ; ) ; (princ) ; ) (setq row 3 col 3) (defun makedclxy (lst row col / ) (setq fo (open (setq dcl (vl-filename-mktemp nil nil ".dcl") ) "w")) ; (setq fo (open "D:\\acadtemp\\test.dcl" "w") ) (if (not makedclxy)(load "make dcl slides xy-2")) (setq x 1 imglst '()) (write-line (strcat "dd" (rtos row 2 0) "x" (rtos col 2 0) " : dialog {") fo) (write-line " label = \"Please choose \" ;" fo) (write-line " : column {" fo) (repeat row (write-line " : column {" fo) (write-line " : row {" fo) (repeat col (write-line " : image_button {" fo) (write-line (strcat " key = \"sq" (rtos x 2 0) "\" ;") fo) (setq imglst (cons (strcat "sq" (rtos x 2 0)) imglst)) (write-line " width = 10 ; " fo) (write-line " aspect_ratio = 1.0 ;" fo) (write-line " color = 0 ;" fo) (write-line " allow_accept = true;" Fo) (setq x (1+ x)) (write-line " }" fo) ) (write-line " }" fo) (write-line " }" fo) (write-line " : column {" fo) (write-line " : row {" fo) (setq x (- x col)) (repeat col (write-line " : text { " fo) (write-line (strcat "key = \"Text" (rtos x 2 0) "\" ;") fo) (write-line (strcat "label = \"" (cadr (nth (- x 1) lst)) "\" ;") fo) (write-line " width = 10 ;" fo) (write-line " fixed_width = true ;" fo) (write-line " alignment = centered ;" fo) (write-line " } " fo) (setq x (1+ x)) ) (write-line " } " fo) (write-line " } " fo) ) (write-line " }" fo) (write-line "ok_cancel ;" fo) (write-line "}" fo) (write-line "}" fo) (close fo) (setq imglst (reverse imglst)) (setq dcl_id (load_dialog "D:\\acadtemp\\test.dcl")) (if (not (new_dialog (strcat "dd" (rtos row 2 0) "x" (rtos col 2 0)) dcl_id)) (exit) ) (setq x -1) (foreach img imglst (setq sldname (car (nth (setq x (1+ x)) lst))) (start_image img) (slide_image 0 0 (- (dimx_tile img) 1) (- (dimy_tile img) 1) sldname) (end_image) ) (foreach sld imglst (action_tile sld "(done_dialog)(setq ans $key)") ) (action_tile "accept" "(done_dialog)") (start_dialog) (unload_dialog dcl_id) (princ ans) (princ) ) For Mhy3sx set the dcl file to a known file then can look at how the dcl would be made. Edited April 18 by BIGAL 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.