Strange lisp error in 2005. Fine in 2000.

Discussion in 'AutoCAD' started by devon, Jul 15, 2004.

  1. devon

    devon Guest

    Hi,

    The following lisp worked fine in 2000, but not in 2005 I get this error... error: bad argument type: numberp: nil.

    This lisp, you pick points over a curve and the lisp inserts a box with the gradient, radius etc filled out.


    (defun dtr (a)
    (* pi (/ a 180.0));................
    );end defun

    (defun rtd (a)
    (* (/ a pi) 180.0);...............
    );end defun



    (defun C:CU ()

    (setq CURVE (nentsel "\nSelect CURVE :.."))

    (setq EN1 (car CURVE))
    (setq EN2 (entget EN1))
    (setq RAD (cdr (assoc 40 EN2)))
    (setq STANGDEG (cdr (assoc 50 EN2)))
    (setq ENANGDEG (cdr (assoc 51 EN2)))

    (setq DEFANGRAD (- ENANGDEG STANGDEG))
    (setq DEFANGDEG (rtd (- ENANGDEG STANGDEG)))

    (setq ARCLENGTH (* RAD DEFANGRAD))
    (setq TANLENGTH (* RAD (/ (sin (/ DEFANGRAD 2)) (cos (/ DEFANGRAD 2)))))

    ; (textpage)
    ; (prompt "\n ......................................................")
    ; (prompt "\n C U R V E I N F O R M A T I O N ")
    ; (prompt "\n ......................................................")

    ; (prompt (strcat "\n. Deflection Angle = " (angtos DEFANGRAD 1 3)))
    ; (prompt (strcat "\n. Radius = "(rtos RAD 2 3)))
    ; (prompt (strcat "\n. Arc Length = "(rtos ARCLENGTH 2 3)))
    ; (prompt (strcat "\n. Tan Length = "(rtos TANLENGTH 2 3)))
    ; (princ)
    ; (prompt "\n ......................................................")
    ; (prompt "\n P L E A S E C O N T I N U E ")
    ; (prompt "\n ......................................................")
    ; (princ)
    (SETVAR "attdia" 0)
    (command "insert" (strcat pathciv "r2") pause "2" "" "" (angtos DEFANGRAD 1 3)
    (rtos RAD 2 3)
    (rtos ARCLENGTH 2 3)
    (rtos TANLENGTH 2 3))
    (SETVAR "attdia" 1)

    )

    Any idea?

    Thanks
     
    devon, Jul 15, 2004
    #1
  2. Finding the cause of the error starts with either running
    the code in the VLIDE or using an *error* function that
    calls (vl-bt) to show the exact expression that failed.

    You haven't taken that first step. Are you expecting
    someone to do it for you?

    (defun *error* (s)
    (vl-bt)
    (princ)
    )

    It will show you what expression threw the error.



    error... error: bad argument type: numberp: nil.
    the gradient, radius etc filled out.
     
    Tony Tanzillo, Jul 15, 2004
    #2
  3. devon

    ECCAD Guest

    Try a (command "-insert"..

    Bob
     
    ECCAD, Jul 15, 2004
    #3
  4. devon

    devon Guest

    Hi,

    thanks Tony for the reply.

    Here is the error list, I am having problems trying to figure out what this means thou...

    Command: cu
    Select CURVE :..Backtrace:
    [0.50] (VL-BT)
    [1.46] (*ERROR* "bad argument type: numberp: nil") LAP+7
    [2.40] (_call-err-hook #<USUBR @09ad7a8c *ERROR*> "bad argument type: numberp:
    nil")
    [3.34] (sys-error "bad argument type: numberp: nil")
    :ERROR-BREAK.29 "bad argument type: numberp: nil"
    [4.26] (- nil 0.0)
    [5.20] (C:CU) LAP+152
    [6.15] (#<SUBR @09adb76c -rts_top->)
    [7.12] (#<SUBR @095c2334 veval-str-body> "(C:CU)" T #<FILE internal>)
    :CALLBACK-ENTRY.6 :)CALLBACK-ENTRY)
    :ARQ-SUBR-CALLBACK.3 (nil 0)

    Would you mind running a newbe through this please?
    Thanks
     
    devon, Jul 16, 2004
    #4
  5. devon

    ECCAD Guest

    In the following:
    --------------
    [3.34] (sys-error "bad argument type: numberp: nil")
    :ERROR-BREAK.29 "bad argument type: numberp: nil"
    [4.26] (- nil 0.0)
    [5.20] (C:CU) LAP+152
    --------------------
    Read from bottom up: It's telling you within 'function' (C:CU), in one of the operations: (can't determine which)..
    (setq DEFANGRAD (- ENANGDEG STANGDEG))
    (setq DEFANGDEG (rtd (- ENANGDEG STANGDEG)))
    the variable 'ENANGDEG' is 'nil' --> [4.26] (- nil 0.0)

    Possible that the entity 'EN2' does not have a (assoc 51) code ?

    Bob
     
    ECCAD, Jul 16, 2004
    #5
  6. devon

    tsparks Guest

    little harsh, don't you think?
     
    tsparks, Jul 16, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.