New tlen.lsp for polylines

New tlen.lsp for polylines

Anonymous
Not applicable
102,810 Views
20 Replies
Message 1 of 21

New tlen.lsp for polylines

Anonymous
Not applicable

Hi guys,

 

I don't use AutoCad so much, in fact I have been hopeless for a while with the new interface, but steadily I'm getting there.

 

It seems with 2010 onwards the area command doesn't work on plines. So that means the famous tlen.lsp doesn't work anymore. I have tried to play around with it myself, but just can't get it to work. (Don't have any experience with lisp). I've tried using the lengthen command instead, but I can't get it to work either.

 

The current lsp is:

 

(defun C:TLENG (/ ss tl n ent itm obj l)
  (setq ss (ssget)
        tl 0
        n (1- (sslength ss)))
  (while (>= n 0)
    (setq ent (entget (setq itm (ssname ss n)))
          obj (cdr (assoc 0 ent))
          l (cond
              ((= obj "LINE")
                (distance (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
              ((= obj "ARC")
                (* (cdr (assoc 40 ent))
                   (if (minusp (setq l (- (cdr (assoc 51 ent))
                                          (cdr (assoc 50 ent)))))
                     (+ pi pi l) l)))
              ((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE")
                   (= obj "LWPOLYLINE")(= obj "ELLIPSE"))
                (command "_.area" "_o" itm)
                (getvar "perimeter"))
              (T 0))
          tl (+ tl l)
          n (1- n)))
  (alert (strcat "Total length of selected objects is " (rtos tl)))
  (princ)
)

 

Can someone guide me please.

Thanks.

Ozitag

0 Likes
Accepted solutions (2)
102,811 Views
20 Replies
Replies (20)
Message 21 of 21

Kent1Cooper
Consultant
Consultant

@dali.j wrote:

.... So where should i add this line? in the beginning of the code?


If you're asking about the line in Message 8, there are several places it could go, but at the very beginning is good.  That's the answer to Message 20, also.

Kent Cooper, AIA
0 Likes