Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

correct this lisp routine please

6 REPLIES 6
Reply
Message 1 of 7
trevon1191
237 Views, 6 Replies

correct this lisp routine please

can anyone run this lisp routine and tell me what is wrong with it. and make corrections to it.  i cant seem to find the problem.

 

(defun C:ELBOW (/*ERROR* ME CE CL)
 (DEFUN NEWERR (MSG)
 (PRINC (STRCAT "\n*ERROR* : "MSG))
 (SETVAR "MENUECHO" ME)
 (SETVAR "CMDECHO" CE)
 (SETVAR "CLAYER" CL)
 (GC) (PRINC)
)
;
 (SETQ ACADERR *ERROR*
 *ERROR* NEWERR
 ME (GETVAR "MENUECHO")
 CE (GETVAR "CMDECHO")
 CL (GETVAR "CLAYER")
)
 ;(SETVAR "MENUECHO" 0)
 ;(SETVAR "CMDECHO" 0)
 ;(GRAPHSCR)
 ;(DEFUN DTR (A)
 ;(* PI (/ A 180.0)))
 ;(DEFUN RTD (A)
 ;(/ (* A 180.0) PI)
😉
 ;(SETQ IP (GETPOINT "\n enter first point "))
 ;(SETQ EW (GETREAL "\n enter elbow width "))
 ;(SETQ E1 (LIST (- (CAR IP)(/ EW 2))(CADR IP)))
 ;(SETQ E2 (LIST (+ (CAR E1) EW)(CADR E1)))
 ;(SETQ E3 (LIST (+ (CAR E2) 6)(+ (CADR E2) 6)))
 ;(SETQ E4 (LIST (CAR E3)(+ (CADR E3) EW)))
 ;(SETQ CP (LIST (+ (CAR E2) 6)(CADR E2)))
 ;(COMMAND "PLINE" E1 E2 "A" "CE" CP "A" -90 "L" E4 "A" "CE" CP E1 "")
;(SETVAR "MENUECHO" ME)
;(SETVAR "CMDECHO" CE)
;(SETVAR "CLAYER" CL)
;(SETQ *ERROR* ACADERR)(GC)
(PRINC)
)

6 REPLIES 6
Message 2 of 7
Kent1Cooper
in reply to: trevon1191

In addition to my comments on the other thread [some of which I see you've already dealt with]:

 

There must be a space between the forward-slash and *error* [or whatever is the first item] in the localized variables list at the top.

 

Semicolons at the beginnings of lines of code "comment them out," so get rid of the semicolons on lines of code that you want to be active.

Kent Cooper, AIA
Message 3 of 7
trevon1191
in reply to: Kent1Cooper

i made the neccessary corrections to the routine. I got this "; error: extra right paren on input" message. But the lisp routine seems to work. I have attached an image so you can that the figure was drawn but I am getting that error message.

Should i be worried about it since it is drawing the figure.

this is the revised routine.

 

(defun C:ELBOW (/ *ERROR* ME CE CL)
(DEFUN *ERROR* (MSG)
(PRINC (STRCAT "\n*ERROR* : "MSG))
(SETVAR "MENUECHO" ME)
(SETVAR "CMDECHO" CE)
(SETVAR "CLAYER" CL)
(PRINC)
)
;
(SETQ
ME (GETVAR "MENUECHO")
CE (GETVAR "CMDECHO")
CL (GETVAR "CLAYER")
)
(SETVAR "MENUECHO" 0)
(SETVAR "CMDECHO" 0)
(GRAPHSCR)
)
(SETQ IP (GETPOINT "\n enter first point "))
(SETQ EW (GETREAL "\n enter elbow width "))
(SETQ E1 (LIST (- (CAR IP)(/ EW 2))(CADR IP)))
(SETQ E2 (LIST (+ (CAR E1) EW)(CADR E1)))
(SETQ E3 (LIST (+ (CAR E2) 6)(+ (CADR E2) 6)))
(SETQ E4 (LIST (CAR E3)(+ (CADR E3) EW)))
(SETQ CP (LIST (+ (CAR E2) 6)(CADR E2)))
(COMMAND "PLINE" E1 E2 "A" "CE" CP "A" -90 "L" E4 "A" "CE" CP E1 "")
;(SETVAR "MENUECHO" ME)
;(SETVAR "CMDECHO" CE)
;(SETVAR "CLAYER" CL)
(PRINC)
)

Message 4 of 7
trevon1191
in reply to: Kent1Cooper

 
Message 5 of 7
trevon1191
in reply to: Kent1Cooper

If it's possible, could you run this command and tell if you encounter any errors.

Message 6 of 7
Kent1Cooper
in reply to: trevon1191

The one after (GRAPHSCR) looks like the culprit.

 

If that's the problem, I would guess that when you load it, it goes into the routine by itself, without your needing to enter the command name, because that right parenthesis completes the (defun) function, and then it proceeds with the functions that follow.

 

I would also guess that it therefore doesn't deal correctly with those System Variables, because the saving of them into variables won't happen without entering the command name.  And that when you do type in the command name, it doesn't work because the operational functions are outside the command definition.  And that if you hadn't commented out the resetting of the System Variables, you'd get an error in the runs-by-itself-on-loading case, because ME would not have been set and it won't like trying to set 'MENUECHO to nil.

 

Take out the extraneous ), and it ought to work [but I didn't try it myself].

Kent Cooper, AIA
Message 7 of 7
trevon1191
in reply to: Kent1Cooper

yes, that was exactly what the problem was. it was running now..

Thank you

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost