Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

New tlen.lsp for polylines

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
ozitag
70698 Views, 20 Replies

New tlen.lsp for polylines

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

IV 2010
20 REPLIES 20
Message 21 of 21
Kent1Cooper
in reply to: dali.j


@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost