polyline length on leader

polyline length on leader

Anonymous
Not applicable
5,957 Views
38 Replies
Message 1 of 39

polyline length on leader

Anonymous
Not applicable

is there a lisp or program where i can click on a polyline and show the length of that line on the end of a leader that i can move around and drop off

0 Likes
Accepted solutions (4)
5,958 Views
38 Replies
Replies (38)
Message 2 of 39

Kent1Cooper
Consultant
Consultant

Would this be always a Leader specified by only  the arrowhead location and one  other point [or, always the same  number of defining points if other than 2], or would the number of defining points need to vary?

 

It shouldn't be hard to do something like that if you don't mind not seeing the length value text until after  you've given it the other end of the Leader.  [It may be possible to get the text in and then let you drag it around, but I think it would be a lot more complicated.]

 

Over in the plain-AutoCAD Forum where you first raised the question, it was about a Line, but here it's about a Polyline, in which case another question arises:  Should it show the length of just the segment you pick on, or of the entire Polyline?

 

You also talked about picking the line, then picking the point on it where you want the Leader arrowhead, but that step is not in the current description.  Does that mean the arrowhead should go at the point where you pick on the Polyline?

 

 

Kent Cooper, AIA
0 Likes
Message 3 of 39

Anonymous
Not applicable

this is for an electrical engineering project.

we are measuring conduit.

what we need is to choose all the pieces of a line. hit enter and have those lengths added up in a que. then select the line to define a leader start point, click on the page and have a leader end point with the total length of lines selected displaying at the end of a leader. 

 

all we need is the total length of the lines selected on the end of a leader.

 

i hope that answers your questions... about my question 🙂

0 Likes
Message 4 of 39

Anonymous
Not applicable

i said polyline, i was incorrect in my verbage. i was talking about multiple lines. they were not drawn with a spline. i dont think.

 

0 Likes
Message 5 of 39

Anonymous
Not applicable

we dont mind seeing the length value until after its dropped off. what we dont want to do is have to look at properties and add up line lengths.

0 Likes
Message 6 of 39

john.uhden
Mentor
Mentor

How about if you just grip the end and drag it where you want?

I don't understand what the length matters.

John F. Uhden

0 Likes
Message 7 of 39

Satish_Rajdev
Advocate
Advocate

Came across to similar thread recently, I hope this will work for you :

http://www.cadtutor.net/forum/showthread.php?104867-Codes-to-Add-Text-only-and-no-need-leader..

 

(defun c:Test ( / s p c a d)
  (vl-load-com)
  (if (and (setq s (car (entsel "\nPick a polyline :")))
         (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
             (alert "Invalid object! Please pick a polyline only.")
             )
         (setq p (getpoint "\nSpecify point perpendicular to polyline :"))
         (setq c (vlax-curve-getclosestpointto s p))
         (setq a (angle p c))
         (not (grdraw p c 1 -1)) ;; rubber line in red colour.
         (setq d (angle '(0. 0. 0.) (vlax-curve-getfirstderiv s (vlax-curve-getparamatpoint s c))))
         (or (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
                 (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
                 )
             (alert "Picked point is not a perpendicular to picked polyline. <!>")
             )
         )
  (command "_.leader" "_non" p "\\" "" (strcat "CHAINAGE = " (rtos (vlax-curve-getdistatpoint s c) 2 4)) "")
  )
(princ)
)

 

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes
Message 8 of 39

Anonymous
Not applicable

we have to call out the length of the conduit on our drawings. so instead of measuring each piece then adding it up, and then tagging the wire with a leader and entering the length 1000's of times we just want to tag each piece and have the length come up with a leader.

 

click click enter boom

 

seconds save minutes, minutes save hours

0 Likes
Message 9 of 39

Anonymous
Not applicable

so went to wordpad and created a .lsp file. but when i try to load it onto autocad using the appload command it cant see the file. i can see it on wordpad with the .lsp extension but i cant see it anywhere else. how do i load the file onto autocad?

0 Likes
Message 10 of 39

Satish_Rajdev
Advocate
Advocate

Just copy that code and past it at command-line... run test command

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

Message 11 of 39

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... choose all the pieces of a line. hit enter and have those lengths added up in a que. then select the line to define a leader start point, click on the page and have a leader end point with the total length of lines selected displaying at the end of a leader. 

 

all we need is the total length of the lines selected on the end of a leader.

....

polyline ... incorrect ... talking about multiple lines

....


 

So, multiple selection of [presumably end-to-end?] Line objects only, but one Leader showing the total of their lengths.  Try this:

 

(defun C:LTLL (/ ss total); = Leader with Total Length of Lines
  (if (setq ss (ssget '((0 . "LINE"))))
    (progn ; then
      (setq total 0)
      (repeat (setq n (sslength ss))
        (setq total
          (+
            total
(vla-get-Length (vlax-ename->vla-object (ssname ss (setq n (1- n))))) ); + ); setq ); repeat (command "_.leader" pause pause "" (rtos total) "" "") ); progn ); if (princ) ); defun (vl-load-com)

 

It uses your current Units length settings for mode and precision in the total-length figure -- if you want something different, add mode and precision arguments in the end of the (rtos) function.

 

It does only a 2-designated-points Leader, but could easily be modified for more than 2 if you always want the same number, or less easily for an indeterminate number of points.

Kent Cooper, AIA
Message 12 of 39

Anonymous
Not applicable

i need to do lines not polylines

0 Likes
Message 13 of 39

Anonymous
Not applicable

ok i didn't know to use the command test. thanks. unfortunately i am not using polylines.

0 Likes
Message 14 of 39

Anonymous
Not applicable

kent can you please just send me a lisp file that i can load

0 Likes
Message 15 of 39

Satish_Rajdev
Advocate
Advocate

Try this :-

 

(defun c:Test ( / s p c a d)
  (vl-load-com)
  (if (and (setq s (car (entsel "\nPick a line :")))
         (or (= (cdr (assoc 0 (entget s))) "LINE")
             (alert "Invalid object! Please pick a polyline only.")
             )
         (setq p (getpoint "\nSpecify point perpendicular to line :"))
         (setq c (vlax-curve-getclosestpointto s p))
         (setq a (angle p c))
         (not (grdraw p c 1 -1)) ;; rubber line in red colour.
         (setq d (angle '(0. 0. 0.) (vlax-curve-getfirstderiv s (vlax-curve-getparamatpoint s c))))
         (or (or (equal (rem (+ d (* pi 0.5)) (+ pi pi)) a 1e-4)
                 (equal (rem (+ d (* pi 1.5)) (+ pi pi)) a 1e-4)
                 )
             (alert "Picked point is not a perpendicular to picked polyline. <!>")
             )
         )
  (command "_.leader" "_non" p "\\" "" (strcat "CHAINAGE = " (rtos (vlax-curve-getdistatpoint s c) 2 4)) "")
  )
(princ)
)

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

Message 16 of 39

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

kent can you please just send me a lisp file that i can load


Try this.

Kent Cooper, AIA
Message 17 of 39

Anonymous
Not applicable

almost there.

 

i need to be able to select more than 1 line and then add them up. they are not poly lines. its really good but not there yet.

 

we have conduit runs that take 90 degree turns we need to add up and give a total length for the run.

 

also can you get it to register in feet and inches?

 

so far so good, you are almost there

0 Likes
Message 18 of 39

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

i need to be able to select more than 1 line and then add them up. they are not poly lines. its really good but not there yet.

we have conduit runs that take 90 degree turns we need to add up and give a total length for the run.

also can you get it to register in feet and inches?

....


 

I don't understand -- it does exactly what you describe, for me.  It doesn't care what direction(s) the Line(s) run or turn [or even whether they are contiguous at their ends as I assume the ones you would select would be].  And if your current Units settings for length are feet and inches, that's what it uses, to your current-settings level of precision.  What are you getting?

Kent Cooper, AIA
0 Likes
Message 19 of 39

Anonymous
Not applicable

on mine when i select a line it only lets me choose the one line. and then it ask me to choose a point perpendicular to the line. and the only thing that it is measuring is the length of where the leader starts away from the line

do i need to change some settings or something?

 

i am using the command test to start using the lisp after i appload it. 

0 Likes
Message 20 of 39

Anonymous
Not applicable

at the end of the leader it says chainage = 23.7859

 

i know thats the measurement from the line to where the leader starts

 

0 Likes