LISP compatibility

HI ! Im still working in V7 as I find the later versions a bit awkward .

I have problems with my old lisps . As I have loads of small lisps that I run time after time one problem is that rightclick does not repeat lisps.

This is propably why this Lisp will not work I think.

[code];
(defun c:langd ()
  (setq total 0)
  (setq loop1 1)
   (while loop1
 (setq e (entnext))
 (COMMAND ".LAYER" "T" "*" "")
    (setq layerpicked
 (CDR (ASSOC 8 (ENTGET (CAR (ENTSEL "\nPeka på ett layer att summera: ")))))
    )
 (COMMAND ".LAYER" "S" layerpicked "")
 (COMMAND ".LAYER" "F" "*" "")
        (setq loop1 nil)
 (setq loop (getstring "Detta är det som räknas OK? j/n [j]"))
  (if (or (= loop "n") (= loop "N") ) (setq loop1 1))
 )

  (princ "\nVänta jag räknar")

  (while e
    (setq enttyp (cdr (assoc 0 (entget e))))
    (setq layername (cdr (assoc 8 (entget e))))
    (setq fg (cdr (assoc 62 (entget e))))


    (if
      (and
        (equal enttyp "LINE")
        (equal layername layerpicked)
 (equal fg 1)
      )
      (add_lines3)
    )
    (if
      (and
        (equal enttyp "LINE")
        (equal layername layerpicked)
 (equal fg 3)
      )
      (add_lines3)
    )
    (if
      (and
        (equal enttyp "LINE")
        (equal layername layerpicked)
 (equal fg 256)
      )
      (add_lines3)
    )
    (if
      (and
        (equal enttyp "ARC")
        (equal layername layerpicked)
 (equal fg 1)
      )
      (add_arcs3)
    )
    (if
      (and
        (equal enttyp "ARC")
        (equal layername layerpicked)
 (equal fg 3)
      )
      (add_arcs3)
    )
    (if
      (and
        (equal enttyp "ARC")
        (equal layername layerpicked)
 (equal fg 256)
      )
      (add_arcs3)
    )

    (setq e (entnext e))
  )
  (terpri)
  (setq total (/ total 1000))
 (COMMAND ".LAYER" "T" "*" "")
  (print layerpicked)
  (strcat "   " (rtos total) "m     ")
 

) ;defun linear

  (defun add_lines3 ()
 (setq p1 (cdr (assoc 10 (entget e))))
        (setq p2 (cdr (assoc 11 (entget e))))
        (setq length (distance p1 p2))
        (setq total (+ length total))
 
  )

 (defun add_arcs3 ()
  (SETQ CEN (CDR (ASSOC 10 (entget e)))
        RAD (CDR (ASSOC 40 (entget e)))
        DIA (* RAD 2.0)
        CIRCUM (* (* RAD PI) 2.0)
        S_ANG (CDR (ASSOC 50 (entget e)))
        E_ANG (CDR (ASSOC 51 (entget e)))
  )
  (IF (< E_ANG S_ANG)
    (SETQ E_ANG (+ E_ANG (* PI 2.0)))
  )
  (SETQ
        N_ANG (- E_ANG S_ANG)
        N_ANG_1 (* (/ N_ANG PI) 180.0)
        PART_CIRC (/ N_ANG_1 360.0) 
        A_LEN (* PART_CIRC CIRCUM)
   )
  (setq total (+ total a_len))
  )[/code]

Could someone tell me whats wrong.

Patrik

Comments

  • one problem is that rightclick does not repeat lisps.

    On V7.1.0018 your lisp works OK and will repeat if you rightclick.

  • YES !

    Sorry , thats why Im still on v7. Hardly any of my LISPs work in 10,11 or 12.

    Patrik

  • Patrick, your code will run on V12.1.10 and repeats if you right click. It will however not add the lengths of entities that have the color Bylayer.

    To solve this change this:
    [code](equal fg 256)[/code]
    Twice to:
    [code](or (not fg) (equal fg 256))[/code]

    You should also look into:
    - Properly indenting your code
    - Localizing your variables
    - (cond)
    - (or)
    - And for V10-12: (vla-get-length).
This discussion has been closed.