Results 1 to 6 of 6

Thread: Polyline Label with a leader

  1. #1
    Active Member
    Join Date
    2015-10
    Posts
    73
    Login to Give a bone
    0

    Default Polyline Label with a leader

    Can anyone help to write a LISP that will label the horizontal length, not to be confused with slope of a polyline, that would include a leader, and an option to input the material of the line(MTEXT)? And of course control of the font.....Oh and one last thing, it only has to label to the nearest foot.

    TIA
    Last edited by rickquin651723; 2016-02-11 at 04:24 PM.

  2. #2
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: Polyline Label with a leader

    Give this a whirl. I assume from your wording you're talking 3d polylines not 2d or lwpoly's. It uses the leader command so arrow style and text font and size are controlled by the active dimstyle. If you use this on non 3d poly's the footage wont be right and it'll probably crash. let me know if you are needing this to work on both 3d and 2d or lwpoly's and can make it work.

    Code:
    (vl-load-com)
    ;this only works as intended on 3d polys, 2d polys give weird results
    (defun c:foo ( / en lst tmp dist str1 str2 pt1 pt2)
    ;change "foo" to whatever command work for you
     (while (not (setq en (ssname (ssget "_+.:E:S" '((0 . "POLYLINE"))) 0))))
     (setq	lst (getcoords en)
    	en (vlax-ename->vla-object en)
    	tmp (list (list (car lst) (cadr lst)))
    	lst (cdddr lst))
     (repeat (/ (length lst) 3)
      (setq	tmp (append tmp (list (list (car lst) (cadr lst))))
    	lst (cdddr lst))
     );end repeat
     (setq lst tmp dist 0.0)
     (repeat (- (length lst) 1)
      (setq	dist (+ dist (distance (car lst) (cadr lst)))
      	lst (cdr lst))
     );end repeat
     (setq	mat (vlax-get en 'Material)
    	str1 (strcat "Horizontal Distance = " (rtos dist 2 0)) str2 (strcat "Material = " mat)
    	pt1 (getpoint "\nPick point for beginning of leader")
    	pt2 (getpoint "\npick point for end of leader"))
     (command "_LEADER" pt1 pt2 "" str1 str2 "")
     (princ)
    );end defun
    
    ;I didnt write this function but don't know whom to give credit, sorry
    (defun getcoords (ent)
      (vlax-safearray->list
        (vlax-variant-value
          (vlax-get-property
    	(vlax-ename->vla-object ent)
    	"Coordinates"
          )
        )
      )
    )
    edit: cleaned code a little, if I knew what units you were measuring in I could add that to the label.
    Last edited by ccalder; 2016-02-23 at 06:53 PM.

  3. #3
    Active Member
    Join Date
    2015-10
    Posts
    73
    Login to Give a bone
    0

    Default Re: Polyline Label with a leader

    Thanks for the reply ccalder, sorry for the delay, I didn't realize you had responded, been so busy I haven't had many opportunities to get back. Then when I did, our post was long gone and buried, found the dealio on my account that tracks what I've posted and viola'!!!
    Anyway, I am in fact working with 2d polylines in profile view. C3D allows you to label lines, but they are labeled with their slope length not the horizontal. I'm gonna attach an image in hopes to better explain myself. Thanks again!

    PV LABEL 2.JPG
    Attached Images Attached Images

  4. #4
    I could stop if I wanted to
    Join Date
    2015-10
    Location
    Central New Jersey
    Posts
    439
    Login to Give a bone
    0

    Default Re: Polyline Label with a leader

    I'm using civil 3D and I'm seeing that the label style can be made to show the horizontal length of a tangent vs the sloped length. Is that not working for you?

    Another option might be to use an Expression for labeling that subtracts the start station of a segment from the end station to arrive at a horizontal value.

  5. #5
    Active Member
    Join Date
    2015-10
    Posts
    73
    Login to Give a bone
    0

    Default Re: Polyline Label with a leader

    I'll check again, what type of label are you using? This brings up another point of contention, I'm drawing my conduit (Pipe network) with a polyline, as I've yet to find a network that looks like what the bosses want. Therefore I'm unable to use the standard pipe labels and networks. I'll attach an image of that as well.
    Thanks for the input.

    PV LABEL 3.JPG

  6. #6
    I could stop if I wanted to
    Join Date
    2015-10
    Location
    Central New Jersey
    Posts
    439
    Login to Give a bone
    0

    Default Re: Polyline Label with a leader

    Ahh, now I understand ... i think. The label I was looking at was a profile label but it was for labeling the tangent sections of a profile. That wouldn't work here. However I did find something that might work.

    Make the conduit polyline into a profile (trace over it with a profile, you can even put in some curves if you want). Then build a General Note label, feature: note, label type: note, in the style add a reference text component for a profile. This reference text component can reach properties of a profile line. There is a property for the profile length .... the total horizontal length.

Similar Threads

  1. 2015: Parcel Label Leader
    By tim_newsome in forum AutoCAD Civil 3D - Parcels
    Replies: 1
    Last Post: 2015-02-12, 03:40 PM
  2. Combining a block and polyline into a leader?
    By --AuBe-- in forum AutoLISP
    Replies: 1
    Last Post: 2011-06-20, 01:24 PM
  3. label polyline?
    By feargt in forum AutoLISP
    Replies: 4
    Last Post: 2009-02-16, 10:04 AM
  4. Dragged label leader toggle.
    By jstew in forum Civil 3D Wish List
    Replies: 0
    Last Post: 2006-02-07, 02:17 PM
  5. LABEL POLYLINE LENGHTS
    By bklagrone in forum AutoLISP
    Replies: 3
    Last Post: 2004-09-23, 09:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •