I need to devide the tlen by 12?

Discussion in 'AutoCAD' started by Mike Shick, Mar 9, 2005.

  1. Mike Shick

    Mike Shick Guest

    I need to devide the tlen by 12 for the following lisp routine...but I'm
    not too familiar with writing lisp.

    Any help?

    ; TOTLEN.LSP c.2000 Rob Herr
    ; 'Add selected lines, plines, splines, and arcs for total length'
    ; v 1.0 10 Feb 2000
    ;
    ; ___________________________________________________________________
    ; | PERMISSION HEREBY GRANTED BLA, BLA, BLA, TO MODIFY ETC. |
    ; | As long as name and email remain with the original program |
    ; | unaltered. However I would like to know of any bugs or problems |
    ; | that arise with the actual program. And of course I take no |
    ; | responsibility for lost limbs, auto repair bills, mechanical |
    ; | or electronic difficulties, or snake venom. |
    ; -------------------------------------------------------------------

    (defun tlines ()
    (setq lbeg (cdr (assoc '10 ent)))
    (setq lend (cdr (assoc '11 ent)))
    (setq llen (distance lbeg lend))
    (setq tlen (+ tlen llen))
    (ssdel sn ss1)
    )

    (defun tarcs ()
    (setq cen (cdr (assoc '10 ent)))
    (setq rad (cdr (assoc '40 ent)))
    (setq dia (* rad 2.0))
    (setq circ (* (* rad pi) 2.0))
    (setq sang (cdr (assoc '50 ent)))
    (setq eang (cdr (assoc '51 ent)))
    (if (< eang sang)
    (setq eang (+ eang (* pi 2.0)))
    )
    (setq tang (- eang sang))
    (setq tang2 (* (/ tang pi) 180.0))
    (setq circ2 (/ tang2 360.0))
    (setq alen (* circ2 circ))
    (setq tlen (+ tlen alen))
    (princ)
    (ssdel sn ss1)
    )

    (defun tplines ()
    (command "area" "e" sn)
    (setq tlen (+ tlen (getvar "perimeter")))
    (ssdel sn ss1)
    )

    (defun tsplines ()
    (command "area" "e" sn)
    (setq tlen (+ tlen (getvar "perimeter")))
    (ssdel sn ss1)
    )

    (DEFUN C:TOTLEN (/ tlen ss1 sn sn2 et)
    (setq cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq tlen 0)
    (prompt "\nSelect only those entities you want for total length: ")
    (setq ss1 (ssget))
    (while (> (sslength ss1) 0)
    (setq sn (ssname ss1 0))
    (setq ent (entget sn))
    (setq et (cdr (assoc '0 ent)))
    (cond
    ((= et "LINE") (tlines))
    ((= et "ARC") (tarcs))
    ((= et "LWPOLYLINE") (tplines))
    ((= et "POLYLINE") (tplines))
    ((= et "SPLINE") (tsplines))
    ((or
    (/= et "LINE")
    (/= et "ARC")
    (/= et "LWPOLYLINE")
    (/= et "POLYLINE")
    (/= et "SPLINE")
    )
    (ssdel sn ss1)
    )
    )
    )
    (alert (strcat "\nThe Total Length of Selected Lines, Polylines, and
    Arcs is: " (rtos tlen 2 5)))
    (setvar "cmdecho" cmdecho)
    (prompt "\nBy Rob Herr ")
    (princ)
    )
     
    Mike Shick, Mar 9, 2005
    #1
  2. Mike Shick

    Jeff Mishler Guest

    (rtos tlen 2 5)
    Find the line above and change it to:
    (rtos (/ tlen 12.0) 2 5)
     
    Jeff Mishler, Mar 9, 2005
    #2
  3. Mike Shick

    krispy Guest

    I have not read all the code so don't know what it does... but if you just want to display the variable tlen divided by 12 at the end then change this line:
    (rtos tlen 2 5)
    to:
    (rtos (/ tlen 12) 2 5)
     
    krispy, Mar 9, 2005
    #3
  4. Mike Shick

    Mike Shick Guest

    Thanks.

    I need spend some time learning the language.

    Mike
     
    Mike Shick, Mar 9, 2005
    #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.