+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Using
    Civil 3D 2008
    Join Date
    May 2010
    Posts
    3

    Default lwpolyline length between specific vertexes

    Registered forum members do not see this ad.

    Hello,
    I am using Civil 3d 2008 and i am looking for a way to "dimension" a polyline between specific vertexes.
    For example if i have a polyline with 50 vertexes and i need to write the length between vertex 1 to 5, then 5 to 12, then 12 to 24 etc. I don't need the dimensions between every vertex but the length of the polyline from vertex i give to another vertex i give. This length must be writen above (in the middle) the measured length. Until now i was doing it manually. Break the polyline==> list==> add text with the length. But it takes to much time to do that. Is there any way to do that quicker?
    Thanks to you all,
    George.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,709

    Default

    This will label them all - you can remove the ones you don't want:

    Code:
    (defun c:LabelSegs ( / *error* spc doc ent flg )
      (vl-load-com)
      ;; Lee Mac  ~  18.05.10
    
      (defun *error* ( msg )
        (and flg (vla-EndUndomark doc))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ))    
    
      (setq spc
        (if
          (or
            (eq AcModelSpace
              (vla-get-ActiveSpace
                (setq doc
                  (vla-get-ActiveDocument
                    (vlax-get-acad-object)
                  )
                )
              )
            )
            (eq :vlax-true (vla-get-MSpace doc))
          )
          (vla-get-ModelSpace doc)
          (vla-get-PaperSpace doc)
        )
      )  
    
      (if
        (setq ent
          (CurveifFoo
            (lambda ( x )
              (eq "LWPOLYLINE"
                (cdr (assoc 0 (entget x)))
              )
            )
            "\nSelect LWPolyline to Label: "
          )
        )
        (
          (lambda ( n / der )
            (setq flg (not (vla-StartUndoMark doc)))        
            (repeat (fix (vlax-curve-getEndParam ent))
              (vla-put-rotation
                (AddText spc
                  (rtos
                    (-
                      (vlax-curve-getDistatParam ent (setq n (1+ n)))
                      (vlax-curve-getDistatParam ent (1- n))
                    )
                  )
                  (polar
                    (vlax-curve-getPointatParam ent (- n 0.5))
                    (+
                      (setq der
                        (angle '(0. 0. 0.)                
                          (vlax-curve-getFirstDeriv ent (- n 0.5))
                        )
                      )
                      (/ pi 2.)
                    )
                    (/ (getvar 'TEXTSIZE) 2.)
                  )
                  (getvar 'TEXTSIZE)
                )
                (MakeReadable der)
              )
            )
            (setq flg (vla-EndUndomark doc))
          )
          (vlax-curve-getStartParam ent)
        )
      )
      (princ)
    )
    
    (defun MakeReadable ( a )
      (cond
        (
          (and (> a (/ pi 2)) (<= a pi))
    
          (- a pi)
        )
        (
          (and (> a pi) (<= a (/ (* 3 pi) 2)))
    
          (+ a pi)
        )
        (
          a
        )
      )
    )
    
    (defun AddText ( block str point height / o )
      (vla-put-Alignment
        (setq o
          (vla-AddText block str
            (vlax-3D-point point) height
          )
        )
        acAlignmentMiddleCenter
      )
      (vla-put-TextAlignmentPoint o (vlax-3D-point point))
      o
    )
    
    (defun CurveifFoo ( foo str / sel ent )
      (while
        (progn
          (setq sel (entsel str))
          
          (cond
            (
              (vl-consp sel)
    
              (if (not (foo (setq ent (car sel))))
                (princ "\n** Invalid Object Selected **")
              )
            )
          )
        )
      )
      ent
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,993
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  4. #4
    Forum Newbie
    Using
    Civil 3D 2008
    Join Date
    May 2010
    Posts
    3

    Default

    Lee Mac and Alanjt, thanks for your quick responce. Unfortunately those lisps doesn't work for what i need to do. Maybe i didn't make my self very clear (my english are not so good). I attach a foto to make it more clear. Let's suppose i have the red lwpoline, and the points A,B,C,D. What i need to do is write the length of the polyline between the points A and B (101.70m), B-C (91.35m), C-D (151.42m), D-A (77.86m), not the "dimaligned" between the vertexes. I hope you can help me.
    George.
    Attached Images

  5. #5
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,993
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  6. #6
    Forum Newbie
    Using
    Civil 3D 2008
    Join Date
    May 2010
    Posts
    3

    Default

    Registered forum members do not see this ad.

    Alanjt, thank you very much for your help. That will save me much time.
    Is it posible the distance between the two points to be writen above the polyline and in the middle of the points?

Similar Threads

  1. Lwpolyline Length (Vertex to vertex)
    By srinivasarajug in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 23rd Jan 2012, 12:05 pm
  2. Count amount blocks and length specific polylines
    By SstennizZ in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 16th Jul 2008, 03:33 pm
  3. An arc with a specific length.
    By kc27315 in forum AutoCAD General
    Replies: 2
    Last Post: 14th Jul 2008, 08:57 pm
  4. insert radiator block & stretch to specific length
    By raj banerjee in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st Aug 2007, 12:11 pm
  5. Total length of specific lines
    By Yamma in forum AutoCAD General
    Replies: 1
    Last Post: 21st Aug 2006, 01:11 pm

Bookmarks

Posting Permissions

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