Code Red > AutoLISP (Vanilla / Visual)
Help: Set drawing scale DCL lisp
mhy3sx:
Hi, I am writing a dcl lisp to set the scale of the drawing, but I have this error
--- Code: ---Error: malformed list on input.
--- End code ---
--- Code - Auto/Visual Lisp: ---(defun c:SETSC (/ *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) ) ; end defun (cond ((not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w") ) ; end setq ) ; end not (princ "\nUnable to open DCL for writing.") ) ((progn (foreach str '( "ed : edit_box { alignment = left; width = 20; edit_width = 10; fixed_width = true;}" "" "setscale : dialog { spacer; key = \"dcl\";" " : boxed_radio_column { key=\042key\042; label = \"Select Drawing Scale;\"; height = 1.0;" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button01\"; label = \"1. --> 1:50\";" " }" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button02\"; label = \"2. --> 1:100\";" " }" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button03\"; label = \"3. --> 1:200\";" " }" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button04\"; label = \"4. --> 1:250\";" " }" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button05\"; label = \"5. --> 1:500\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button06\"; label = \"6. --> 1:2000\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button07\"; label = \"7. --> 1:2500\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button08\"; label = \"8. --> 1:5000\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button09\"; label = \"9. --> 1:10000\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button10\"; label = \"10. --> 1:50000\";" " }" ; radio_button " : ed {height = 1.0; width = 20; is_tab_stop = true;key = \"other\"; label = \"Other:\"; }" " }" ;end boxed_column " ok_only;" " }" ; end dialog ) ;end list (write-line str des) ) ; end foreach (setq des (close des) dch (load_dialog dcl) ) ; end setq (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ((not (new_dialog "setscale" dch)) (princ "\nUnable to display 'setscale' dialog.") ) (t (set_tile "dcl" "Select Drawing Scale") (action_tile "key" "(setq sngReturn $value)") (action_tile "OK" "(done_dialog 1)") (start_dialog) (setvar "OSMODE" 13) (princ "\n The dawing scale set 1:")(princ newsc)(princ) (if (setq sngReturn (cond ((eq sngReturn "radio_button01") 50) ((eq sngReturn "radio_button02") 100) ((eq sngReturn "radio_button03") 200) ((eq sngReturn "radio_button04") 250) ((eq sngReturn "radio_button05") 500) ((eq sngReturn "radio_button06") 2000) ((eq sngReturn "radio_button07") 2500) ((eq sngReturn "radio_button08") 5000) ((eq sngReturn "radio_button09") 10000) ((eq sngReturn "radio_button10") 50000) ((eq sngReturn "other") (setq sngReturn (get_tile "other")) ) )) (princ "\nThe drawing scale is 1:")(princ sngReturn) (setq newsc (getint "\nThe new scale is 1:")) (setvar "useri1" newsc) ) ) ; end cond (*error* nil))
Any ideas?
Thanks
BIGAL:
Just use this, it can be used in any code just save to a support path so autoloads. Just look at the examples say the 1 2 3 .........
mhy3sx:
Hi BIGAL, I have seen this code before but I can not understand it. Can you Help me with my code?
Thanks
ribarm:
Here is your code debugged...
I hope you'll learn something - that error of yours is common for unbalanced brackets, but you had more lacks...
What I discovered more is that EDIT BOX don't work in BricsCAD, but works as desired in AutoCAD - tested on release 2022...
--- Code - Auto/Visual Lisp: ---(defun c:SETSC (/ *error* dch dcl des sng sngReturn ) (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 = 25; edit_width = 10; fixed_width = true;}" "" "setscale : dialog { spacer; key = \"dcl\";" " : boxed_radio_column { key=\042key\042; label = \"Select Drawing Scale\"; height = 1.0;" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button01\"; label = \"1. --> 1:50\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button02\"; label = \"2. --> 1:100\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button03\"; label = \"3. --> 1:200\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button04\"; label = \"4. --> 1:250\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button05\"; label = \"5. --> 1:500\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button06\"; label = \"6. --> 1:2000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button07\"; label = \"7. --> 1:2500\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button08\"; label = \"8. --> 1:5000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button09\"; label = \"9. --> 1:10000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button10\"; label = \"10. --> 1:50000\";" " }" " : ed {height = 1.0; width = 25; is_tab_stop = true;" " key = \"other\"; label = \"Other:\";" " }" " }" " ok_only;" " }" ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ((not (new_dialog "setscale" dch)) (princ "\nUnable to display 'setscale' dialog.") ) (t (set_tile "dcl" "Select Drawing Scale") (action_tile "key" "(progn (setq sngReturn (atoi (get_tile \"other\"))) (setq sng $value))") (action_tile "OK" "(done_dialog 1)") (start_dialog) (if (setq sngReturn (cond ( (eq sng "radio_button01") 50 ) ( (eq sng "radio_button02") 100 ) ( (eq sng "radio_button03") 200 ) ( (eq sng "radio_button04") 250 ) ( (eq sng "radio_button05") 500 ) ( (eq sng "radio_button06") 2000 ) ( (eq sng "radio_button07") 2500 ) ( (eq sng "radio_button08") 5000 ) ( (eq sng "radio_button09") 10000 ) ( (eq sng "radio_button10") 50000 ) ( (eq sng "other") sngReturn ) ) ) (progn (princ "\nThe drawing scale is 1:")(princ sngReturn) (setvar "useri1" sngReturn) (initget 4) (if (setq newsc (getint "\nThe new scale is (ENTER to discard) 1:")) (setvar "useri1" newsc) ) ) ) ) ) (*error* nil))
HTH.
M.R.
mhy3sx:
Hi ribarm. I test your code . I see that the other scale is not working in ZWCAD I use. I add some more things in the code but the other scale not working.
Any other ideas how to fix this problem?
--- Code - Auto/Visual Lisp: ---(defun c:SETSC (/ *error* dch dcl des sng sngReturn cursc newsc) (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) ) (setvar "OSMODE" 13) (setq cursc (getvar "useri1")) (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 = 25; edit_width = 10; fixed_width = true;}" "" "setscale : dialog { spacer; key = \"dcl\";" " : boxed_radio_column { key=\042key\042; label = \"Select Drawing Scale\"; height = 1.0;" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button01\"; label = \"1. --> 1:50\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button02\"; label = \"2. --> 1:100\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button03\"; label = \"3. --> 1:200\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button04\"; label = \"4. --> 1:250\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button05\"; label = \"5. --> 1:500\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button06\"; label = \"6. --> 1:2000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button07\"; label = \"7. --> 1:2500\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button08\"; label = \"8. --> 1:5000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button09\"; label = \"9. --> 1:10000\";" " }" " : radio_button { height = 1.0; width = 25; is_tab_stop = true;" " key = \"radio_button10\"; label = \"10. --> 1:20000\";" " }" " : ed {height = 1.0; width = 25; is_tab_stop = true;" " key = \"other\"; label = \"Other:\";" " }" " : ed {height = 1.0; width = 25; is_enabled = false;" " key = \"oldscale\"; label = \"Old Scale:\";" " }" " }" " ok_only;" " }" ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ((not (new_dialog "setscale" dch)) (princ "\nUnable to display 'setscale' dialog.") ) (t (set_tile "dcl" "Select Drawing Scale") (set_tile "oldscale" (itoa cursc)) ; set the old scale in the dialog box (action_tile "key" "(progn (setq sngReturn (atoi (get_tile \"other\"))) (setq sng $value))") (action_tile "OK" "(done_dialog 1)") (start_dialog) (if (setq sngReturn (cond ( (eq sng "radio_button01") 50 ) ( (eq sng "radio_button02") 100 ) ( (eq sng "radio_button03") 200 ) ( (eq sng "radio_button04") 250 ) ( (eq sng "radio_button05") 500 ) ( (eq sng "radio_button06") 2000 ) ( (eq sng "radio_button07") 2500 ) ( (eq sng "radio_button08") 5000 ) ( (eq sng "radio_button09") 10000 ) ( (eq sng "radio_button10") 20000 ) ( (eq sng "other") sngReturn) ( (eq sng "oldscale") cursc) ) ) (progn (princ "\nThe drawing scale is 1:")(princ sngReturn) (setvar "useri1" sngReturn) ) ) ) ) (*error* nil))
Thansk
Navigation
[0] Message Index
[#] Next page
Go to full version