Results 1 to 3 of 3

Thread: Distance between Polyline vertices

  1. #1
    Login to Give a bone
    0

    Default Distance between Polyline vertices

    Hi all,


    Is there any way to get the distance between polyline vertices and create a text between the vertices? For example, if I have a polyline with 5 vertices, I would like the distance between vertices 1-2, 2-3, 3-4, etc and then create a text with the values(distance) between the vertices. Ideally, I would like to use this for any kind of polyline (2D, 3D, etc).


    Many thanks for your help.

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Distance between Polyline vertices

    Hi,

    My contribution

    Code:
    (vl-load-com)
    (defun c:label_dist-vertex_po ( / js htx AcDoc Space nw_style n obj ename pr dist_start dist_end pt_start pt_end seg_len alpha nw_obj)
      (princ "\nSelect polylines.")
      (while
        (null
          (setq js
            (ssget
              '(
                (0 . "*POLYLINE")
                (-4 . "<NOT")
                  (-4 . "&") (70 . 112)
                (-4 . "NOT>")
              )
            )
          )
        )
        (princ "\nSelect is empty, or isn't POLYLINE!")
      )
      (initget 6)
      (setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify height text <" (rtos (getvar "TEXTSIZE")) ">: ")))
      (if htx (setvar "TEXTSIZE" htx))
      (setq
        AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
        Space
        (if (= 1 (getvar "CVPORT"))
          (vla-get-PaperSpace AcDoc)
          (vla-get-ModelSpace AcDoc)
        )
      )
      (cond
        ((null (tblsearch "LAYER" "Label"))
          (vlax-put (vla-add (vla-get-layers AcDoc) "Label") 'color 96)
        )
      )
      (cond
        ((null (tblsearch "STYLE" "Romand-Label"))
          (setq nw_style (vla-add (vla-get-textstyles AcDoc) "Romand-Label"))
          (mapcar
            '(lambda (pr val)
              (vlax-put nw_style pr val)
            )
            (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
            (list "romand.shx" 0.0 (/ (* 15.0 pi) 180) 1.0 0.0)
          )
        )
      )
      (repeat (setq n (sslength js))
        (setq
          obj (ssname js (setq n (1- n)))
          ename (vlax-ename->vla-object obj)
          pr -1
        )
        (repeat (fix (vlax-curve-getEndParam ename))
          (setq
            dist_start (vlax-curve-GetDistAtParam ename (setq pr (1+ pr)))
            dist_end (vlax-curve-GetDistAtParam ename (1+ pr))
            pt_start (vlax-curve-GetPointAtParam ename pr)
            pt_end (vlax-curve-GetPointAtParam ename (1+ pr))
            seg_len (- dist_end dist_start)
            alpha (angle (trans pt_start 0 1) (trans pt_end 0 1))
          )
          (setq nw_obj
            (vla-addMtext Space
              (vlax-3d-point (setq pt (polar (vlax-curve-GetPointAtParam ename (+ 0.5 pr)) (+ alpha (* pi 0.5)) (getvar "TEXTSIZE"))))
              0.0
              (rtos seg_len 2 2)
            )
          )
          (mapcar
            '(lambda (pr val)
              (vlax-put nw_obj pr val)
            )
            (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
            (list 8 (getvar "TEXTSIZE") 5 pt "Romand-Label" "Label" alpha)
          )
        )
      )
      (prin1)
    )

  3. #3
    Login to Give a bone
    0

    Default Re: Distance between Polyline vertices

    Thanks Mr. Bruno.Valsecchi. It's perfect.

Similar Threads

  1. Distance and azimuth between vertices of a polyline in c#
    By rodrigo_gcmsoft in forum Dot Net API
    Replies: 10
    Last Post: 2011-05-04, 11:02 AM
  2. How to change polyline vertices?
    By rdogomes in forum AutoLISP
    Replies: 12
    Last Post: 2010-04-01, 11:26 PM
  3. Distance between polyline vertices
    By lmitsou in forum AutoLISP
    Replies: 6
    Last Post: 2008-10-21, 12:41 PM
  4. Add vertices to a 3d Polyline
    By td729 in forum AutoCAD Civil 3D - General
    Replies: 17
    Last Post: 2008-06-17, 04:49 PM
  5. No. of Vertices in a PolyLine
    By snviswanadha in forum AutoLISP
    Replies: 20
    Last Post: 2006-10-11, 01:50 PM

Tags for this Thread

Posting Permissions

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