Author Topic: HELP PLEASE! bad argument type: stringp nil  (Read 12427 times)

0 Members and 1 Guest are viewing this topic.

jermjmm

  • Guest
HELP PLEASE! bad argument type: stringp nil
« on: October 19, 2007, 10:47:24 AM »
having an issue with a program that I've been working on. when i try to run this lisp it says: bad argument type: stringp nil
i've used the same expressions in other lisps and they worked, I don't have a clue as to why it's not working now.


Code: [Select]
;;; INSERTS TEXT ON LINE

(defun C:Ty (/ A1 A2 A3 E1 E2 E3 ENTNA LASTX OS1 P1 P4 P5 P6 P7 P8 P9 TX TX1)
  (setq OS1 (getvar "osmode"))
  (setvar "osmode" 512)
  (if (= txold "")
    (setq txold "1")
  )
  (setq TX (getstring (strcat "\nEnter text <" txold ">: ")))
  (if (= tx "")
    (setq tx txold)
  )
  (setq txold tx)
  (while (setq E1 (entsel "\nSelect Line: "))
    (setq E2 (entget (car E1)))
    (setq lay (cdr (assoc 8 E2)))
    (command "-layer" "s" lay "")
    (setq E3 (cdr (assoc 0 E2)))
    (setq P1 (cdr E1))
    (setq P1 (car P1))

    (if (= E3 "POLYLINE")
      (setq P2 (cadr E1)
            P3 (getpoint "\nPick point for rotation: ")
      )

      (if (= E3 "CIRCLE")
        (setq P2 (cadr E1)
              P3 (cdr (assoc 10 E2))
        )

        (if (= E3 "ARC")
          (setq P2 (cadr E1)
                P3 (cdr (assoc 10 E2))
          )

          (setq P2 (cdr (assoc 10 E2))
                P3 (cdr (assoc 11 E2))
          )
        )
      )
    )

    (if (= E3 "CIRCLE")
      (setq A1 (+ (angle P2 P3) (/ pi 2)))

      (if (= E3 "ARC")
        (setq A1 (+ (angle P2 P3) (/ pi 2)))

        (setq A1 (angle P2 P3))
      )
    )
    (if (> A1 (/ pi 2))
      (setq A2 (angtos (+ A1 pi) 0 4))
    )
    (if (<= A1 (* pi 1.5))
      (setq A2 (angtos (+ A1 pi) 0 4))
    )
    (if (<= A1 (/ pi 2))
      (setq A2 (angtos (* A1 1) 0 4))
    )
    (if (> A1 (* pi 1.5))
      (setq A2 (angtos (* A1 1) 0 4))
    )
    (command "TEXT" "M" P1 A2 TX)
    (setvar "osmode" OS1)

    (setq LASTX (entget (entlast)))
    (setq TX1 (textbox LASTX))
    (setq P4 (car TX1))
    (setq P5 (cdr TX1))
    (setq P5 (car P5))
    (setq P6 (distance P4 P5))
    (setq P7 (+ (/ P6 2) (* 0.04 (getvar 'dimscale))))

    (setq A3 (- A1 pi))
    (setq p8 (polar P1 A1 P7))
    (setq p9 (polar P1 A3 P7))
    (command "ERASE" "L" "")
    (command "BREAK" P1 "F" P8 P1)
    (command "BREAK" P1 P9)
    (command "OOPS")
    (setvar "osmode" 512)
  )
  (princ)
)

<edit: code tags added>
« Last Edit: October 19, 2007, 11:00:51 AM by CAB »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #1 on: October 19, 2007, 10:55:01 AM »
Sorry, I don't have time to investigate.

If you define this error handler --

(defun *error* (x) (vl-bt))

-- and then run your program you should be able to quickly determine the source of the problem.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #2 on: October 19, 2007, 11:05:39 AM »
Try using this:
Code: [Select]
  (if (or (null txold) (= txold ""))
    (setq txold "1")
  )
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.

jermjmm

  • Guest
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #3 on: October 19, 2007, 11:34:42 AM »
thanks cab!

changed the front end to look like this:

(defun C:Ty (/ A1 A2 A3 E1 E2 E3 ENTNA LASTX OS1 P1 P4 P5 P6 P7 P8 P9 TX TX1)
  (setq OS1 (getvar "osmode"))
  (setvar "osmode" 512)
  (if (or (nULL txold) (= txold ""))
    (setq txold "1")
  )
  (setq TX (getstring (strcat "\nEnter text <" txold ">: ")))
  (if (or (nULL tx) (= tx ""))
    (setq tx TXOLD)
  )
  (setq txold tx)
 (while (setq E1 (entsel "\nSelect Line: "))


works great now!

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #4 on: October 19, 2007, 01:56:04 PM »
« Last Edit: October 19, 2007, 02:01:45 PM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

jermjmm

  • Guest
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #5 on: October 19, 2007, 02:03:38 PM »
 :-D I figured it would get someone's attention.

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #6 on: October 19, 2007, 02:08:27 PM »
:-D I figured it would get someone's attention.
Funny cause I usually ignore threads with titles like that--and if i dont, i wont give any help pertaining to the persons question-. ...I should start giving responses like those thread titles --``RTFM''.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

jermjmm

  • Guest
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #7 on: October 19, 2007, 02:10:41 PM »
ah, your no fun. . . just kidding.

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #8 on: October 19, 2007, 02:13:53 PM »
ah, your no fun. . . just kidding.
Also funny cause im actually one of the un-serious persons you could ever meet -- 'cept when it comes to thread titles i guess-.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #9 on: October 19, 2007, 03:22:13 PM »
maybe I'm slow, but I don't see anything wrong with the thread title.....and I coulda swore it's the same now as when I first saw it around 8 this morning (PDT).

jermjmm

  • Guest
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #10 on: October 19, 2007, 03:25:58 PM »
just to let everybody know, i've done some revisions on it and it's working good.  can't say it's the best way to code but then again i've only been learning lisp for about 1 to 2 months.

Code: [Select]
;;; INSERTS TEXT ON LINE

(defun C:Ty (/ A1 A2 A3 E1 E2 E3 ENTNA LASTX OS1 P1 P4 P5 P6 P7 P8 P9 TX TX1)
  (SETQ OLDL (GETVAR "CLAYER"))
  (setq OS1 (getvar "osmode"))
  (setvar "osmode" 512)
  (if (or (nULL txold) (= txold ""))
    (setq txold "1")
  )
  (setq TX (getstring (strcat "\nEnter text <" txold ">: ")))
  (if (or (nULL tx) (= tx ""))
    (setq tx TXOLD)
  )
  (setq txold tx)
  (while (setq E1 (entsel "\nSelect Line: "))
   (setq E2 (entget (car E1)))
   (setq lay (cdr (assoc 8 E2)))
   (command "-layer" "s" lay "")
   (setq E3 (cdr (assoc 0 E2)))
   (setq P1 (cadr E1))

   (if (= E3 "POLYLINE")
      (setq P2 (cadr E1)
            P3 (getpoint "\nPick point for rotation: "))

      (if (= E3 "CIRCLE")
         (setq P2 (cadr E1)
               P3 (cdr (assoc 10 E2)))

         (if (= E3 "ARC")
           (setq P2 (cadr E1)
                 P3 (cdr (assoc 10 E2)))

      (setq P2 (cdr (assoc 10 E2))
            P3 (cdr (assoc 11 E2)))
         )
      )
   )

   (if (= E3 "CIRCLE")
      (setq A1 (+ (angle P2 P3) (/ pi 2)))

      (if (= E3 "ARC")
         (setq A1 (+ (angle P2 P3) (/ pi 2)))

         (setq A1 (angle P2 P3))
      )
   )
   (if
   (and
   (> A1 (/ pi 2))
   (<= A1 (* pi 1.5))
   )
   (setq A1 (+ A1 pi))
   )
   (setq A2 (angtos A1 0 4))

   (command "TEXT" "M" P1 A2 TX)


   (setq LASTX (entget (entlast)))
   (setq TX1 (textbox LASTX))
   (setq P4 (car TX1))
   (setq P5 (cdr TX1))
   (setq P5 (car P5))
   (setq P6 (distance P4 P5))
   (setq P7 (+ (/ P6 2) (* 0.04 (getvar 'dimscale))))

   (setq A3 (- A1 pi))
   (setq p8 (polar P1 A1 P7))
   (setq p9 (polar P1 A3 P7))
   (command "ERASE" "L" "")
   (command "BREAK" P1 "F" P8 P1)
   (command "BREAK" P1 P9)
   (command "OOPS")
  )
   (SETVAR "CLAYER" OLDL)
   (setvar "osmode" OS1)
   (princ)
)


<edited to add code tags>
« Last Edit: October 19, 2007, 09:50:05 PM by Keith™ »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #11 on: October 19, 2007, 08:15:39 PM »
:-D I figured it would get someone's attention.
Funny cause I usually ignore threads with titles like that--and if i dont, i wont give any help pertaining to the persons question-. ...I should start giving responses like those thread titles --``RTFM''.

Yep, titles are a pet peeve of mine also.

... along with certain styles of avatar picture  :|
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>
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #12 on: October 19, 2007, 08:17:48 PM »
Sorry, I don't have time to investigate.

If you define this error handler --

(defun *error* (x) (vl-bt))

-- and then run your program you should be able to quickly determine the source of the problem.

it's a pity that this good advice appeared to be ignored.
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.

sinc

  • Guest
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #13 on: October 20, 2007, 10:57:36 AM »
Sorry, I don't have time to investigate.

If you define this error handler --

(defun *error* (x) (vl-bt))

-- and then run your program you should be able to quickly determine the source of the problem.

it's a pity that this good advice appeared to be ignored.

Yep.  That backtrace should point right to the problem.

The debugger can be immensely helpful, too, but last I checked, the VLIDE won't pop open to the site of the exception the way VS Express does for .NET programming.  But single-stepping through the code should have turned it up pretty fast, too.

These tools are a programmer's best friend.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: HELP PLEASE! bad argument type: stringp nil
« Reply #14 on: October 20, 2007, 11:07:41 AM »
Quote
but last I checked, the VLIDE won't pop open to the site of the exception
No but Ctrl-F9 [LastBreak] highlites the break.
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.