Lisp help

Discussion in 'AutoCAD' started by tader, Aug 6, 2004.

  1. tader

    tader Guest

    hi, why does this stop right after the while and not assign values to the preceding variables? BTW I'm trying to check the endpoints of two lines to make sure that they are they same for survey boundary work.

    TIA Shawn

    (defun c:ce (/)
    (while
    (setq ent (nentsel)
    a (entget (car ent)) ; all attributes
    b (cdr (assoc 10 a)) ; E N EL
    c (list (car b) (cadr b)) ; E N ENDPOINT 1
    d (cdr (assoc 11 a))
    e (list (car d) (cadr d)) ; E N ENDPOINT 2
    lst1 (append lst1 c e)
    ) ;end of setq
    ) ;end while
    (setq a1 (list (nth 0 lst1) (nth 1 lst1))
    a2 (list (nth 2 lst1) (nth 3 lst1))
    b1 (list (nth 4 lst1) (nth 5 lst1))
    b2 (list (nth 6 lst1) (nth 7 lst1)))
    )
     
    tader, Aug 6, 2004
    #1
  2. tader

    tader Guest

    I C, I PUT the end of while at the end of the lisp and it works, just doesn't make since. the list (lst1) is already created why does the extractor (nth & car function) need to be inside of the loop?
     
    tader, Aug 6, 2004
    #2
  3. No not really. Your while loop continues until you don't select a
    line. Then (entget (car ent)) errors out because ent is nil. a1, a2,
    b1, & b2 never get set.
    I still don't quite understand exactly what you're trying to
    accomplish.

    --
    Ken Alexander
    Acad2004
    Windows XP

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein

    just doesn't make since. the list (lst1) is already created why does
    the extractor (nth & car function) need to be inside of the loop?
     
    Ken Alexander, Aug 6, 2004
    #3
  4. tader

    Tom Smith Guest

    You've put all your setq's in the while test, and nothing inside the while loop. This guarantees a crash as soon as the first setq of the bunch returns nil. Your while loop says:

    (while (setq_everything)
    ;nothing at all here
    )

    It should say:

    (while (setq ent (nentsel))
    (setq_everything_else)
    )

    This will exit the loop correctly as soon as ent isn't selected.
     
    Tom Smith, Aug 7, 2004
    #4
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.