TrueLength Lisp routine

Discussion in 'AutoCAD' started by kevinpaul, Jul 9, 2004.

  1. kevinpaul

    kevinpaul Guest

    I cant get it to function in AutoCAD 2004. I have zero knowledge of the lisp language so i am of no help. Here is the code:

    (defun c:tl (/ A B C D E tlength obslist mtest alength)
    (setq tlength 0)
    obslist
    )
    (list "ARC" "CIRCLE" "ELLIPSE" "LINE" "POLYLINE" "SPLINE" "LWPOLYLINE")
    (prompt "\nSelect objects:")
    (setq a (ssget))
    (setq b (sslength a))
    (setq c 0)
    (while (<= 1 B)
    (setq D (ssname A C))
    (setq mtest (member (cdr (assoc 0 (entget D))) obslist))
    (if (= mtest nil)
    (prompt "\nThis object has no length definition.")
    (progn
    (command "lengthen" d "")
    (setq alength (getvar "perimeter")
    tlength (+ alength tlength)
    )
    )
    )
    (setq B (- B 1)
    C (+ C 1)
    )
    )
    (prompt "\n============================")
    (prompt "\nTotal: ")
    (princ (rtos tlength 4 3))
    (princ " = ")
    (princ (rtos tlength 2 3))
    (princ " inches")
    (prin1)

    Any help would be greatly apperciated.
     
    kevinpaul, Jul 9, 2004
    #1
  2. kevinpaul

    Paul Turvill Guest

    As an alternative try TLEN.LSP from
    http://www.turvill.com/t2/free_stuff
    ___

    lisp language so i am of no help. Here is the code:
     
    Paul Turvill, Jul 9, 2004
    #2
  3. kevinpaul

    zeha Guest

    Modified

    (defun c:tl (/ A B C D E tlength obslist alength)
    (setq tlength 0)
    (prompt "\nSelect objects:")
    (setq a (ssget '((-4 . "<OR")(0 . "ARC")(0 . "CIRCLE")(0 . "ELLIPSE")(0 . "*LINE")(-4 . "OR>"))))
    (setq b (sslength a))
    (setq c 0)
    (while (<= 1 B)
    (setq D (ssname A C))
    (command "lengthen" d "")
    (setq alength (getvar "perimeter") tlength (+ alength tlength) B (- B 1) C (+ C 1))
    )
    (prompt "\n============================")
    (prompt "\nTotal: ")
    (princ (rtos tlength 4 3))
    (princ " = ")
    (princ (rtos tlength 2 3))
    (princ " inches")
    (prin1)
    )

    cheers
     
    zeha, Jul 9, 2004
    #3
  4. kevinpaul

    kevinpaul Guest

    You sir are a genius! thank you very much.
     
    kevinpaul, Jul 9, 2004
    #4
  5. kevinpaul

    Paul Turvill Guest

    (setq a (ssget '((0 . "ARC,CIRCLE,ELLIPSE,LINE"))))
    will also work.

    "*LINE")(-4 . "OR>"))))
     
    Paul Turvill, Jul 9, 2004
    #5
  6. kevinpaul

    Rudy Tovar Guest

    Condense it

    (setq a (ssget '((0 . "ARC,CI*,EL*,LI*"))))

    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 9, 2004
    #6
  7. Which would be a bad idea if you consider custom objects.

    --
    R. Robert Bell


    Condense it

    (setq a (ssget '((0 . "ARC,CI*,EL*,LI*"))))
     
    R. Robert Bell, Jul 9, 2004
    #7
  8. kevinpaul

    Rudy Tovar Guest

    You had to throw a wrench in there, didn't you...?

    Then again it depends on whether they're using a custom object or bare
    autocad.
     
    Rudy Tovar, Jul 9, 2004
    #8
  9. autocad.


    True. However, if you get files from outside the office, you have no idea
    what might be there.
     
    R. Robert Bell, Jul 9, 2004
    #9
  10. kevinpaul

    Rudy Tovar Guest

    It's good to have a good sense of humor...

    I thought I'd make you laugh...
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 9, 2004
    #10
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.