Jump to content

Recommended Posts

Posted

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

Posted

Latest version of that LISP is here 

 

  • Like 1
Posted
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 

Posted
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.

  • Like 1
Posted
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.

image.thumb.png.5bca21a5079c6e2b4c3ec703971b6682.png

Posted
3 minutes ago, rahil40 said:

image.thumb.png.5bca21a5079c6e2b4c3ec703971b6682.png

;
; 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  

 

image.png

Posted (edited)
44 minutes ago, rahil40 said:

image.thumb.png.5bca21a5079c6e2b4c3ec703971b6682.png

 

@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 by pkenewell
  • Thanks 1
Posted (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 🥰

 

Screenshot2025-02-14095145.png.8f520c3bb92224234c4c27f7f05817cb.png

Edited by rahil40
Posted

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)

Posted
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 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...