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

How to get a each length of pline ?

3 REPLIES 3
Reply
Message 1 of 4
nychoe1
867 Views, 3 Replies

How to get a each length of pline ?

pline_jpg.jpg

 

How to get a each length of pline ?

first, select all object and then

write that length of each object on the each pline objects of MID-POINT ...

 

 

Refer to LISP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; how to edit?

 

(defun c:plen ()
(setvar "cmdecho" 0)
(setq ent (ssget '((0 . "POLYLINE,LWPOLYLINE"))))
(setq n 0 dis 0)
(repeat (sslength ent)
(setq ent_l (ssname ent n))
(command "lengthen" ent_l "")
(setq dis (+ dis (GETVAR "PERIMETER")))
(setq n (1+ n))
)
(prompt (strcat "\nselect ="(rtos n)" total = " (rtos dis)))(princ)
(setvar "cmdecho" 1)
)

 

 

 

 

 

3 REPLIES 3
Message 2 of 4
greg_battin
in reply to: nychoe1

Here's one from Tharwat over at CADTutor.net.

 

It can be easily modified to suite your needs.

 

;; Labels the length of polylines and aligns
;; Tharwat
;; http://www.cadtutor.net/forum/showthread.php?76205-Need-Little-Help-with-my-Lisp-File/page2
(defun c:LabelLength (/ _Text s)
;;; Tharwat 23. Dec. 2012 ;;;
(vl-load-com)
  (defun _Text (p a d)
    (entmakex (list '(0 . "TEXT")
                    (cons 10 (trans p 1 0))
                    (cons 11 (trans p 1 0))
                    (cons 1 (rtos d 2))
                    (cons 50 a)
                    '(40 . 2.)
                    (cons 7 (getvar 'textstyle))
                    '(71 . 0)
                    '(72 . 1)
              )
    )
  )
  (if (setq s (ssget '((0 . "LINE,LWPOLYLINE"))))
    ((lambda (i / e sn pt p p1 p2 st nd ang)
       (while (setq sn (ssname s (setq i (1+ i))))
         (setq e (entget sn))
         (if (eq (cdr (assoc 0 e)) "LWPOLYLINE")
           (progn (setq pt 0)
                  (repeat (- (fix (vlax-curve-getendparam sn)) (fix (vlax-curve-getstartparam sn)))
                    (setq p (mapcar (function (lambda (j k) (/ (+ j k) 2.)))
                                    (setq p1 (vlax-curve-getpointatparam sn pt))
                                    (setq p2 (vlax-curve-getpointatparam sn (setq pt (1+ pt))))
                            )
                    )
                    (_Text p (angle p1 p2) (distance p1 p2))
                  )
           )
           (progn (setq ang (angle (setq st (cdr (assoc 10 e))) (setq nd (cdr (assoc 11 e)))))
                  (_Text (mapcar (function (lambda (j k) (/ (+ j k) 2.))) st nd) ang (distance st nd))
           )
         )
       )
     )
      -1
    )
  )
  (princ)
)

 

Message 3 of 4
Kent1Cooper
in reply to: nychoe1


@nychoe1 wrote:

 

How to get a each length of pline ?

first, select all object and then

write that length of each object on the each pline objects of MID-POINT ...

....

(prompt (strcat "\nselect ="(rtos n)" total = " (rtos dis)))(princ)
(setvar "cmdecho" 1)
....


I had a routine with many of the ingredients to do what you're looking for already in it, which I edited quickly; it works for me in limited testing.  It works on any object(s) with finite length, i.e. Lines, Circles, Arcs, Splines, Ellipses, in addition to Polylines.  For Polylines of multiple segments, it places the Text at the overall midpoint -- I hope that's appropriate.  See the ALL CAPITALS EDIT instructions in the code.  It could be expanded to work in different coordinate systems, or to specify the Layer for the labels [or put them on the Layer of each object], etc., if desired.

Kent Cooper, AIA
Message 4 of 4
nychoe1
in reply to: nychoe1

thank you.

 

I got that I want LSP..

 

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

Post to forums  

Autodesk Design & Make Report

”Boost