Author Topic: lisp error in ACAD2004  (Read 5750 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
lisp error in ACAD2004
« on: March 14, 2005, 03:00:10 PM »
I tried using CAB's insulation lisp in ACAD2004 and I get this error message
Code: [Select]
; error: An error has occurred inside the *error* functionFunction cancelled

this is his routine
Code: [Select]
;;Routine to draw insulation symbol into roof/ wall sections
;;written by Andrew NIELSEN Melbourne Australia - andysan1@bigpond.com
;; call as <INSUL>
;;first pick origin of insulation ; second pick end of insulation
;;third pick height of insulation from first pick
;; draws polyline onto layer "insulation"

;;  Modified by Charles Alan Butler  02/10/2004
;;  Altered error checking & added mirror option

(defun C:INSUL (/ SP EP HT OM CE BM DX AN NX NU pt
             AX PX P1 P2 P3 P4 P5 P6 P7 P8 P9 XT SLST)
             
;; error function & Routine Exit
 (defun *error* (msg)
  (if (not(member msg
   '("console break" "Function cancelled" "quit / exit abort" "")
      ))
     (princ (strcat "\nError: " msg))
  ) ; endif
    ;;reset all variables here
    (command".LAYER""S"CLYR"")
    (setvar"OSMODE" OS)
    (setvar"ORTHOMODE" OM)
    (setvar"CMDECHO" CE)
    (setvar"BLIPMODE" BM)
    (command".UNDO""end")
    (princ)
  ) ;end error function
  (defun os:off(); set osmode off & keep settings
    (if (<= (getvar "osmode") 15359)
     (setvar "osmode" (boole 6 (getvar "osmode") 16384)))
  ); defun
 
  ;; start routine
  (command".UNDO""group")
  (setq OS (getvar "OSMODE"))   (setvar "OSMODE" 512)
  (setq OM (getvar "ORTHOMODE"))(setvar "ORTHOMODE" 1)
  (setq CE (getvar "CMDECHO"))  (setvar "CMDECHO" 0)
  (setq BM (getvar "BLIPMODE")) (setvar "BLIPMODE" 0)
  (while (= SP nil) (setq SP
    (getpoint "\nPick Start Point of Insulation (Ortho  ON; O/S  Near):  ")))
  (while (= EP nil) (setq EP
    (getpoint SP "\nPick Ending Point of Insulation:  ")))
  (os:off)
  (while (= ht nil)
     (setq ht (getdist EP "\nPick or Enter Height of Insulation: ")))
  (if (and sp ep ht)
    (progn
  (setq CLYR (getvar"CLAYER"))
  (command".LAYER""M""XXFINE""C""8""""")
  (setq AN (angle SP EP)
        DX (distance SP EP)
        NX (/ HT 2)
        NU (/ DX NX)
        NX (/ HT 2)
        AX (+ AN (/ PI 2))
        PX (polar SP AX HT)
        P1 (polar SP AX (/ HT 1.25))
        P2 (polar P1 AN (/ HT 20))
        P3 (polar P1 AN (/ HT 4))
        P4 (polar P2 AN (/ HT 2.5))
        P5 (polar SP AX (/ HT 5))
        P6 (polar P5 AN (/ HT 5))
        P7 (polar P6 AN (/ HT 10))
        P8 (polar P5 AN (/ HT 2))
        P9 (polar SP AN (/ HT 2))
  )
  (setq SLST (ssadd))
  (repeat (fix NU)
    (command ".ARC" "C" P5 SP P6)
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P6 P2 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" P2 "C" P3 "A" "-180" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P4 P7 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" "C" P8 P7 P9)
    (setq SLST (ssadd (entlast) SLST))
    (setq SP (polar SP AN NX)
          P2 (polar P2 AN NX)
          P3 (polar P3 AN NX)
          P4 (polar P4 AN NX)
          P5 (polar P5 AN NX)
          P6 (polar P6 AN NX)
          P7 (polar P7 AN NX)
          P8 (polar P8 AN NX)
          P9 (polar P9 AN NX)
    )
  )

  (setq XT (distance SP EP))
  (if (>= XT (/ HT 5))
  (progn
    (command ".ARC" "C" P5 SP P6 )
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P6 P2 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" P2 "C" P3 "A" "-75")
    (setq SLST (ssadd (entlast) SLST))
  )); end if
  (command ".PEDIT" "L" "Y" "J" SLST "" "")
  (initget "Yes No")
  (setq ans (getkword "Mirror Insulation? <No> "))
  (if (= ans "Yes")
    (command ".mirror" "L" "" sp ep "Y")
  )
  )); endif (and sp ep pt)
  (*error* "")
 
);end
(princ)

I tested this in ACAD 2000 and it worked fine.  I beleive the error happens somewhere here
Code: [Select]
(setq SLST (ssadd))
  (repeat (fix NU)
    (command ".ARC" "C" P5 SP P6)
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P6 P2 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" P2 "C" P3 "A" "-180" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P4 P7 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" "C" P8 P7 P9)
    (setq SLST (ssadd (entlast) SLST))
    (setq SP (polar SP AN NX)
          P2 (polar P2 AN NX)
          P3 (polar P3 AN NX)
          P4 (polar P4 AN NX)
          P5 (polar P5 AN NX)
          P6 (polar P6 AN NX)
          P7 (polar P7 AN NX)
          P8 (polar P8 AN NX)
          P9 (polar P9 AN NX)
    )
  )

  (setq XT (distance SP EP))
  (if (>= XT (/ HT 5))

SMadsen

  • Guest
lisp error in ACAD2004
« Reply #1 on: March 14, 2005, 06:11:01 PM »
Before anything else, localize the *error* function (and let it stay local). Then set a breakpoint within it, force the error again and test each of the vars in the *error* function on break.

danny

  • Guest
lisp error in ACAD2004
« Reply #2 on: March 14, 2005, 07:44:47 PM »
I'm not sure how to localize the error function.  I've tried this
Code: [Select]
;; error function & Routine Exit
 (defun *error* (msg)
  (if (or(= msg "Function cancelled") (/= msg "quit / exit abort"))
     (princ (strcat "Error: " msg))
  ) ; endif
    ;;reset all variables here
    (command".LAYER""S"CLYR"")
    (setvar"OSMODE" OS)
    (setvar"ORTHOMODE" OM)
    (setvar"CMDECHO" CE)
    (setvar"BLIPMODE" BM)
    (command".UNDO""end")
    (princ)
  ) ;end error function

but still get the same thing.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #3 on: March 14, 2005, 08:04:33 PM »
This may give you the idea danny ..
defun C:INSUL (/ *error* < .. SNIP .. >

Code: [Select]
(defun C:INSUL (/  *error*  SP EP HT OM CE BM DX AN NX NU pt
             AX PX P1 P2 P3 P4 P5 P6 P7 P8 P9 XT SLST)
             
;; error function & Routine Exit
 (defun *error* (msg)
  (if (not(member msg < .. SNIP .. >
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #4 on: March 14, 2005, 08:09:57 PM »
Long story short ..
because you did not have the *error* function name included in your local variable list for the main procedure, the *error*  function becomes global and overwrites any previous default that has been set, and that another procedure may depend on.

This may not be the cause of your current issues, but is an example of 'best practices' that you should endevour to follow.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #5 on: March 14, 2005, 08:19:27 PM »
I just loaded the file into AC2005 and it ran without error < changed the local variable first.

Note that Andrew NIELSEN < original Author >  is from Australia where we use the metric system, so check the procedure for any hard coded variables that may cause problems.

Misplaced expectation is generally the cause of errors in situations like this.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
lisp error in ACAD2004
« Reply #6 on: March 14, 2005, 08:20:58 PM »
Thanks for the explanation Kerry.  I did what you advise, but you are right, that did not solve the issue.
The routine has an error when trying to join the line and arc's together as a pline.
Code: [Select]
(command ".PEDIT" "L" "Y" "J" SLST "" "")
so am I on the right track looking at this
Code: [Select]
(setq SLST (ssadd)) :roll:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #7 on: March 14, 2005, 08:24:37 PM »
Do you get an actual error message ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
lisp error in ACAD2004
« Reply #8 on: March 14, 2005, 08:56:11 PM »
i get this
Code: [Select]
; error: An error has occurred inside the *error* functionFunction cancelled

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
lisp error in ACAD2004
« Reply #9 on: March 14, 2005, 09:06:28 PM »
I don't have 2005 to test on, but I would try to join the arc and line at the command line and follow the prompts. If the command prompts changes bewteen version based on what you have selected, that will cause the error you show.

Just a thought......

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
lisp error in ACAD2004
« Reply #10 on: March 14, 2005, 09:16:50 PM »
After reading my last few posts, it has become quite clear that I can no longer type quickly on this friggin' sub-standard keyboard they put in my laptop.....between fingers that no longer move well (and are 'larger' than at any other time in my life due to substantial weight gain caused by quitting smoking), the beginnings og arthritis, and the 'closeness' of it all, I have begun to spew gibberish from the keys...... :?

So my otions as I see them:
1. Slow down while typing.....
2. Quit posting
3. Go back to smoking....NEVER!
4. Investigate liposuction for fingers
5. Quit using my laptop
6. Voice recognition software
7. Keep going back and editing the posts after I post and catch the errors.... :oops:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #11 on: March 14, 2005, 09:21:32 PM »
ok, lets try this.
In the VL editor ..

MENU Debug -> Break on error : toggle it so there is a tick

< .. >
)  < -ADD A BREAKPOINT HERE !!  place the cursor then F9

(command ".PEDIT" "L" "Y" "J" slst "" "")

< .. >

Still in the editor ;
Select the Load Active Edit Window button from the Tools Toolbar

at command line  INSUL
The routine will run the prompts, draw the insul' and then stop at the breakpoint you set.

Back in the editor ;
The Debug Toolbar, Select Step Into button < left button  ::  or F8
Keep Clicking till the routine stops.

Where does it stop ?

You may need to read the help Debugging Programs if you get stumped on this procedure.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
lisp error in ACAD2004
« Reply #12 on: March 14, 2005, 09:25:17 PM »
Quote from: Jeff_M

5. Quit using my laptop


I know that feeling .. my fingers are too old and blunt to use a laptop keyboard well ... :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
lisp error in ACAD2004
« Reply #13 on: March 14, 2005, 09:27:07 PM »
Jeff,
you forgot
8. just don't worry about it.
you know, as lnog as the fisrt and last lettres are rihgt, we'll know what yuor saying.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
lisp error in ACAD2004
« Reply #14 on: March 14, 2005, 11:51:40 PM »
danny
Here is the revised routine.
Looks like ACAD2004+ has a new variable PEDITACCEPT that alters the prompts
when creating new plines. That was causing the error.
Code: [Select]
;;Routine to draw insulation symbol into roof/ wall sections
;;written by Andrew NIELSEN Melbourne Australia - andysan1@bigpond.com
;; call as <INSUL>
;;first pick origin of insulation ; second pick end of insulation
;;third pick height of insulation from first pick
;; draws polyline onto layer "insulation"

;;  Modified by Charles Alan Butler  02/10/2004
;;  Altered error checking & added mirror option
;;  Modified by Charles Alan Butler  03/14/2005
;;  Added support for ACAd2004+ sysvar PEDITACCEPT

(defun C:INSUL (/ *error* os:off SP EP HT OM CE BM DX AN NX NU pt
             AX PX P1 P2 P3 P4 P5 P6 P7 P8 P9 XT SLST)
             
;; error function & Routine Exit
 (defun *error* (msg)
  (if (not(member msg
'("console break" "Function cancelled" "quit / exit abort" "")
      ))
     (princ (strcat "\nError: " msg))
  ) ; endif
    ;;reset all variables here
    (command".LAYER""S"CLYR"")
    (setvar"OSMODE" OS)
    (setvar"ORTHOMODE" OM)
    (setvar"CMDECHO" CE)
    (setvar"BLIPMODE" BM)
    (command".UNDO""end")
    (princ)
  ) ;end error function
  (defun os:off(); set osmode off & keep settings
    (if (<= (getvar "osmode") 15359)
     (setvar "osmode" (boole 6 (getvar "osmode") 16384)))
  ); defun
 
  ;; start routine
  (command".UNDO""group")
  (setq OS (getvar "OSMODE"))   (setvar "OSMODE" 512)
  (setq OM (getvar "ORTHOMODE"))(setvar "ORTHOMODE" 1)
  (setq CE (getvar "CMDECHO"))  (setvar "CMDECHO" 0)
  (setq BM (getvar "BLIPMODE")) (setvar "BLIPMODE" 0)
  (while (= SP nil) (setq SP
    (getpoint "\nPick Start Point of Insulation (Ortho  ON; O/S  Near):  ")))
  (while (= EP nil) (setq EP
    (getpoint SP "\nPick Ending Point of Insulation:  ")))
  (os:off)
  (while (= ht nil)
     (setq ht (getdist EP "\nPick or Enter Height of Insulation: ")))
  (if (and sp ep ht)
    (progn
  (setq CLYR (getvar"CLAYER"))
  ;;(command".LAYER""M""INSULATION""C""8""""")
  ;;  USE CURRENT LAYER, ELSE CHECK FOR FROZEN BEFORE MAKE LAYER
 
  (setq AN (angle SP EP)
        DX (distance SP EP)
        NX (/ HT 2)
        NU (/ DX NX)
        NX (/ HT 2)
        AX (+ AN (/ PI 2))
        PX (polar SP AX HT)
        P1 (polar SP AX (/ HT 1.25))
        P2 (polar P1 AN (/ HT 20))
        P3 (polar P1 AN (/ HT 4))
        P4 (polar P2 AN (/ HT 2.5))
        P5 (polar SP AX (/ HT 5))
        P6 (polar P5 AN (/ HT 5))
        P7 (polar P6 AN (/ HT 10))
        P8 (polar P5 AN (/ HT 2))
        P9 (polar SP AN (/ HT 2))
  )
  (setq SLST (ssadd))
  (repeat (fix NU)
    (command ".ARC" "C" P5 SP P6)
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P6 P2 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" P2 "C" P3 "A" "-180" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P4 P7 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" "C" P8 P7 P9)
    (setq SLST (ssadd (entlast) SLST))
    (setq SP (polar SP AN NX)
          P2 (polar P2 AN NX)
          P3 (polar P3 AN NX)
          P4 (polar P4 AN NX)
          P5 (polar P5 AN NX)
          P6 (polar P6 AN NX)
          P7 (polar P7 AN NX)
          P8 (polar P8 AN NX)
          P9 (polar P9 AN NX)
    )
  )

  (setq XT (distance SP EP))
  (if (>= XT (/ HT 5))
  (progn
    (command ".ARC" "C" P5 SP P6 )
    (setq SLST (ssadd (entlast) SLST))
    (command ".LINE" P6 P2 "" )
    (setq SLST (ssadd (entlast) SLST))
    (command ".ARC" P2 "C" P3 "A" "-75")
    (setq SLST (ssadd (entlast) SLST))
  )); end if

  ;;  required for ACAD 2004+
  (if (and (wcmatch (getvar "ACADVER") "*16*")
           (= (getvar "peditaccept") 1))
    (command ".PEDIT" "L" "J" SLST "" "")
    (command ".PEDIT" "L" "Y" "J" SLST "" "")
  )
 
  (initget "Yes No")
  (setq ans (getkword "Mirror Insulation? <No> "))
  (if (= ans "Yes")
    (command ".mirror" "L" "" sp ep "Y")
  )
  )); endif (and sp ep pt)
  (*error* "")
 
);end
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.