rahil40 Posted February 13 Posted February 13 Dear all the members and moderators, Good morning to you all have a nice day. i have some issue in the AutoLISP program, which i used from in this form, really good It works well for me, but I have an issue with some error when I use the escape (Esc) button on the keyboard to cancel the program. I lost my OSNAP mode 0; the OSNAP did not restore the previous mode. At the same time, if I am close by the exit program, its working properly. I dont know why and I try to solve some error set RMD2_SET somewhere in the MF code, but my bad luck, its not successful. so please, someone help me to sort out the problem Very helpful Here i attached the AutoLISP file thank you best regards Rahil RMD2_V4.lsp Quote
SLW210 Posted February 13 Posted February 13 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. 1 Quote
rahil40 Posted February 13 Author Posted February 13 28 minutes ago, SLW210 said: Latest version of that LISP is here hi gentlemen, Thanks for your reply. and i thanks to mr. buzzard making this program for hvac duct drawing really great Actually, i went to the page but i didn't get the problem of my issue is that I get the code from the page which you shared link, after using the AutoLISP, i noticed the problem just few months before the program working well there is no issue but when I'm using the program, i abort or cancel the function by escape button; i lost my osnap mode so how can i solve the error control in the main function thank you Quote
Tharwat Posted February 13 Posted February 13 In the following link you can find all my HVAC programs on my website. NOTE: Trial versions are old now but latest versions are advanced and dynamic ones. https://autolispprograms.wordpress.com/hvac/ 1 Quote
pkenewell Posted February 13 Posted February 13 18 minutes ago, rahil40 said: but when I'm using the program, i abort or cancel the function by escape button; i lost my osnap mode so how can i solve the error control in the main function Tharwat's program has an error handler that should reset the object snap modes and other settings. I don't know what you are doing to lose them. I suggest testing by setting explicit object snaps, then cancelling the program to see what changed. I also recommend that you don't use escape to exit a program, but enter out of it in a normal manner. 1 Quote
rahil40 Posted February 13 Author Posted February 13 4 minutes ago, pkenewell said: Tharwat's program has an error handler that should reset the object snap modes and other settings. I don't know what you are doing to lose them. I suggest testing by setting explicit object snaps, then cancelling the program to see what changed. I also recommend that you don't use escape to exit a program, but enter out of it in a normal manner. Quote
rahil40 Posted February 13 Author Posted February 13 3 minutes ago, rahil40 said: ; ; F20 - Program Loop Function. ; (defun RMD2_PL () (initget 8 "Y N") (setq LOOP$ (cond ((getkword (strcat"\nInsert another duct component? <Y>es or <N>o. <"LOOP$">: "))) (T LOOP$))) (cond ((= LOOP$ "Y")(RMD2_MF)) ((= LOOP$ "N")(RMD2_RUS))) (princ)) ; hi brother if i am using yes no condition the program works sometime accidentally press escape button. I am facing the problem i need to know the after-loop yes/no condition need for cancel or console break operation code something thank you Quote
pkenewell Posted February 13 Posted February 13 (edited) 44 minutes ago, rahil40 said: @rahil40 OK - find the function "RMD2_SET" (or "RMD_SET" in the V6 version) in the lsp file and make the following change. Try it and let us know if that did the trick: (defun RMD2_SET (ERRORMSG) ;(command nil nil nil) ; <--- Comment this out by leading it with a semi-colon (command-s)(command-s) ; <--- Add this line (if (not (member ERRORMSG '("console break" "Function cancelled"))) (princ (strcat "\nError:" ERRORMSG))) (if SUS (mapcar 'setvar SUS_LIST SUS)) (princ "\nAttention!....A user error has occurred.") (princ "\nThe program will now restore the user settings and exit.") (terpri) (setq *error* TERR$) (princ)) (EDIT: Tested and corrected earlier replacement) Edited February 13 by pkenewell 1 Quote
rahil40 Posted February 14 Author Posted February 14 (edited) 7 hours ago, pkenewell said: @rahil40 OK - find the function "RMD2_SET" (or "RMD_SET" in the V6 version) in the lsp file and make the following change. Try it and let us know if that did the trick: (defun RMD2_SET (ERRORMSG) ;(command nil nil nil) ; <--- Comment this out by leading it with a semi-colon (command-s)(command-s) ; <--- Add this line (if (not (member ERRORMSG '("console break" "Function cancelled"))) (princ (strcat "\nError:" ERRORMSG))) (if SUS (mapcar 'setvar SUS_LIST SUS)) (princ "\nAttention!....A user error has occurred.") (princ "\nThe program will now restore the user settings and exit.") (terpri) (setq *error* TERR$) (princ)) (EDIT: Tested and corrected earlier replacement) Good morning, brother. I want to thank you very much for saving my time. Your code is working. I tried it before in both the main and loop functions, but it didn't work for me. Sincere gratitude, fantastic heartly thanks Edited February 14 by rahil40 Quote
Steven P Posted February 14 Posted February 14 What is your LISP ability like? In your code you have about 3 instances where you set the variable "OSMODE" - this is the system variable that controls snapping. What might be considered good practice would be to record the current value, do what you need to do and then reset it as soon as you can: (setq OS_Old (getvar "OSMODE")) ; record snap setting (setvar "OSMODE" -NEW VALUE-) ; set to no snaps ...do stuff.... (setvar "OSMODE" OS_Old) ; reset snaps You also could record the snaps setting at the start of the LISP and in the case of an error use an "error trapping" routine to reset this for you. In your code though you only set OSMODE to 0 in line 343, I don't think you need that and it can be commented out... and you comment out the problem (put a ; at the start of the line) Quote
rahil40 Posted February 14 Author Posted February 14 24 minutes ago, Steven P said: What is your LISP ability like? In your code you have about 3 instances where you set the variable "OSMODE" - this is the system variable that controls snapping. What might be considered good practice would be to record the current value, do what you need to do and then reset it as soon as you can: (setq OS_Old (getvar "OSMODE")) ; record snap setting (setvar "OSMODE" -NEW VALUE-) ; set to no snaps ...do stuff.... (setvar "OSMODE" OS_Old) ; reset snaps You also could record the snaps setting at the start of the LISP and in the case of an error use an "error trapping" routine to reset this for you. In your code though you only set OSMODE to 0 in line 343, I don't think you need that and it can be commented out... and you comment out the problem (put a ; at the start of the line) hi steven, the expected problem solved to me @pkenewell solved the issue with a small command code. Thanks for the support, Steven. "In your code, though, you only set OSMODE to 0 in line 343, I don't think you need that and it can be commented out... and you comment out the problem (put a ; at the start of the line)." yes you are right, i checked this line 343 osmode 0, that also will do same your instruction thank you regards, rahil 1 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.