svorgodne Posted September 18, 2013 Share Posted September 18, 2013 I have the problem I am running a variable script on dozens of files in one shot. And sometimes the script crashes when there is a false command input. So I am looking for a solution which can stop the process when a failure is found and continue with the next two and final commands so the process can continue until all files were done as you can see in the attached script. open "name_01.dwg" LINE 0,0 100,100 (command) qsave close open "name_02.dwg" LINE 0,0 100,100 (command) qsave close open "name_03.dwg" LINE 0,0 100,100 (command) qsave close I have tried (command) and it is not always working. The code: \U+001B works beyond expectetions because it stops completely the process and cannot activate somehow the "resume"command. Any ideas? Thanks in advance Sergio Quote Link to comment Share on other sites More sharing options...
Tuns Posted September 19, 2013 Share Posted September 19, 2013 Is the code VBA? Quote Link to comment Share on other sites More sharing options...
svorgodne Posted September 19, 2013 Author Share Posted September 19, 2013 No, It is a simple script I run with the normal Script command from AutoCAD. If it helps to know. I am writing all my programs in AutoLisp. Thx Quote Link to comment Share on other sites More sharing options...
Tuns Posted September 19, 2013 Share Posted September 19, 2013 Wouldn't you just add a (princ) in it? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 19, 2013 Share Posted September 19, 2013 That's just how Scripts work... They stop executing when an error is encountered. If it helps to know. I am writing all my programs in AutoLisp. Post your code? Quote Link to comment Share on other sites More sharing options...
Tuns Posted September 19, 2013 Share Posted September 19, 2013 Yes, we need to see your code. We could guess all day at a solution and never find one if we can't see it. Quote Link to comment Share on other sites More sharing options...
dbroada Posted September 19, 2013 Share Posted September 19, 2013 That's just how Scripts work... They stop executing when an error is encountered. from experience I would say they don't stop, they just try to interpret each new line as the next typed input. Sometimes you're lucky with that result, sometimes you're unlucky. Either way you will probably wish it had just stopped. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 19, 2013 Share Posted September 19, 2013 Greeting, Dave... It's been a while; hope all is well with you. from experience I would say they don't stop, they just try to interpret each new line as the next typed input. Sometimes you're lucky with that result, sometimes you're unlucky. Either way you will probably wish it had just stopped. I was speaking generally, of course... You are correct with the actual sequence of events, I was merely pointing out that the requested behavior of upon error, resuming in order to successfully complete the others actions on other Documents is not possible. Especially given that the OP has identified that they've ported this task over to LISP, I didn't see the point in elaborating when making my earlier post. Cheers Quote Link to comment Share on other sites More sharing options...
svorgodne Posted September 19, 2013 Author Share Posted September 19, 2013 Here it is the lisp. Like I said before, the routine from "stopping-resuming" the script is sometimes working and sometimes not (setq files (list)) (setq command_list (list)) (defun fn_name_dwg () (setq name_dwg (getfiled "Select drawings to edit" "" "dwg" 8 ) ) (if (= (vl-string-search "\\" name_dwg) nil) (setq name_dwg (strcat (getvar 'dwgprefix) name_dwg)) ) ) (defun lst_files () (fn_name_dwg) (setq files (append files (list name_dwg ) ) ) (setq files (vl-sort files '<)) (setq lst_ord (list)) (foreach miembro files (if (not (member miembro lst_ord)) (setq lst_ord (append lst_ord (list miembro))) ) ) (setq files lst_ord) ) (defun cmmd () (textscr) (princ "\nEnter valid commands to process drawings\n\n" ) (while (/= commands (strcase "END")) (setq commands (strcase (getstring t "type \"END\" when ur done - "))) (setq command_list (append command_list (list commands))) ) (setq commands nil) (setq cnt (length command_list)) (setq command_list (vl-remove (nth (- cnt 1) command_list) command_list)) ) (defun run () (setq command_list (append (list "(defun stop () (command) (command \"resume\"))") command_list)) (setq command_list (cons "open" command_list)) (setq command_list (append command_list (list "(stop)" "qsave" "close") ) ) (setq write_name (strcat (getenv "tmp") "\\" "run_script.scr")) (setq write_scr (open write_name "w")) (setq cnt_1 1) (setq cnt_cmd (length command_list)) (foreach miembro files (if (setq write (open miembro "a")) (progn (close write) (write-line (car command_list) write_scr) (write-line (strcat "\"" miembro "\"") write_scr) (while (< cnt_1 cnt_cmd) (write-line (nth cnt_1 command_list) write_scr) (setq cnt_1 (+ cnt_1 1)) (princ) ) (setq cnt_1 1) ) (princ (strcat "\n" miembro)) ) (princ) ) (close write_scr) (command "_.script" write_name) ) -------------------------------- (defun master () (setq xxxx "") (setq yyyy "") (while (= xxxx "") (lst_files) (setq xxxx (getstring "Enter whatever key or enter to keep looking for files")) ) (while (/= yyyy "") (cmmd) (setq yyyy (getstring "Enter whatever key or enter to keep looking for files")) ) (run) ) -------------------------------- (master) Thanks again Quote Link to comment Share on other sites More sharing options...
Tuns Posted September 20, 2013 Share Posted September 20, 2013 I'm not a LISP genius like Black Box over there, but I'd say that it looks fine to me. Quote Link to comment Share on other sites More sharing options...
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.