+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Jul 2009
    Posts
    37

    Drawing Divide a polyline at equal intervals and extract coordinates in excel

    Registered forum members do not see this ad.

    Dear cadtutors,

    is there any lisp to do the following.
    divide polylines into equal intervals and add vertex to ploylines and label the vertex and extract the coordinates to excel.

    my situation is.

    I have a number of polylines at different position of different length.

    need to divide the polylines at defined uniform intervals. (presently I am doing it by means of measure command, block method)

    Join all blocks generated by measure command along with the verticies of the polyline in the series.

    Label the Blocks/Vertex with the numbers usually with a suffix in series of the flow. Sometimes need to show the easting and northing at the vertex itself.

    Extract the coordinates to excel with the label.
    Attached Files

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,090

    Default

    The intervals (distance) between each vertex on your sample is very unusual. it doesnt follow a pattern (or maybe i just dont see it), sometimes it starts at the end and some the intervals are form a vertex along the pline? going towrads the other direction?

    Can you be more precise in describing the intervals?

  3. #3
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Jul 2009
    Posts
    37

    Default

    Hai pBe,

    In the attached drawings the interval is 200m and if the vertex falls before 200m then the vertex is taken without dividing the polyline.

    If the vertex is falling in between the 200m division and it is some what closer to the previous or next block (as in this drawing) may within 60-80m. then that block is ignored & the previous or next block may be slghtly more than 200m. For the surveyors convinience I have made it this way.

    You can try for uniform intervals.

  4. #4
    Super Member Organic's Avatar
    Discipline
    Civil
    Using
    Civil 3D 2013
    Join Date
    Feb 2009
    Posts
    1,641

    Default

    Are you looking for a chainage lisp?

  5. #5
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Jul 2009
    Posts
    37

    Default

    Hai Dink,

    I am looking for a coordinate lisp rather than chainage lisp, But a chainage lisp will also be useful.

  6. #6
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Jun 2011
    Posts
    2

    Default

    Dear Cad Tutors

    I have the same problem to solve, please, I would appreciate if you can send me the lisp application.

    Thanks a lot.

  7. #7
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    The answer was above just search "chainage" "divide" "vertex" there at least 3 lsp's for chainages or points along a pline.

    Chlabeller.lsp ? label station ?

    Another search can not remember lsp name
    ;; ;;
    ;; Divides selected objects into an LWPolyline with a ;;
    ;; specified number of segments ;;
    ;;------------------------------------------------------------;;
    ;; Author: Lee McDonnell, 2010 ;;
    ;; ;;
    ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
    ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
    ;;--

  8. #8
    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,710

    Default

    Quote Originally Posted by BIGAL View Post
    Another search can not remember lsp name
    http://lee-mac.com/segmentcurve.html
    Lee Mac Programming

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

    Just another Swamper

  9. #9
    Senior Member
    Computer Details
    VVA's Computer Details
    Operating System:
    Windows 7
    CPU:
    Intel Core i5-2400
    RAM:
    8 Gb
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    Seagate 500 GB + WD 750 GB
    Monitor:
    Philips 27"
    Using
    AutoCAD 2013
    Join Date
    Dec 2006
    Location
    Minsk, Belarus
    Posts
    401

    Default

    still a variant: download archives, load pltools.fas or pltools.lsp and type in command line pl-divall. The length of the segment - a negative number, the number of segments - a positive number.
    To extract coordinates of excell:
    Point manager
    Lisp: coordinates of points to excel sheet (+point number)
    Export coordinates (both Geodetic and Mathematical)

  10. #10
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Registered forum members do not see this ad.

    Try this quick & dirty lisp, just change an interval and other stuffs inside the code
    Code:
    (defun C:plb (/ acapp acpt acsp ang cnt cur_length datafile div ent ep filename gap i p pline pline_num pt
             pt_list seg_length sp step str_text txtpt txt_height verts x)
    (vl-load-com)
     
    (defun rem_dupes  (lst prec)
      (if lst
        (cons (car lst)
       (rem_dupes
         (vl-remove-if '(lambda(x)(equal x (car lst) prec)) lst) prec)
         )
       )
        )
    (setq acsp (vla-get-block
            (vla-get-activelayout
       (vla-get-activedocument
         (setq acapp (vlax-get-acad-object))))
            )
     )
    (setq pt_list nil div 100.0)
     
    (setq ent (entsel "\n\tSelect polyline >> "))
     
    (setq pline (vlax-ename->vla-object (car ent)))
    (setq verts (vl-remove-if 'not
           (mapcar '(lambda(x)(if (= 10 (car x))(trans (cdr x) 0 1)))
            (entget (car ent))))
          ) 
    (setq cur_length 0.)
    (repeat (1- (length verts))
      (setq sp (car verts)
     ep (cadr verts)
     pt_list (cons sp pt_list)
     )
      (setq seg_length
      (distance sp ep)
     step 0.)
      (if (> seg_length div)
        (repeat (fix (/ seg_length div))
          (setq cur_length (+ cur_length div))
          (if (and (setq pt (vlax-curve-getpointatdist pline cur_length))
            (> (distance pt ep) div))
     (setq pt_list (cons (vlax-curve-getclosestpointto pline pt) pt_list))
     )
          )
        )
      (setq verts (cdr verts))
      )
    (setq pt_list (cons (vlax-curve-getendpoint pline) pt_list))
    (setq pt_list (reverse (rem_dupes pt_list 1.0)))
    (setq pline_num (getint "\n\tPline label number: "))
     
    (setq cnt  0
          txt_height 25
          gap  (* 2 txt_height))
     
    (mapcar '(lambda (pt)
        (setq ang (angle '(0 0 0)
           (trans (vlax-curve-getFirstDeriv
             pline
             (vlax-curve-getParamAtPoint pline (trans pt 1 0)))
           0
           1
           T)))
        (setq txtpt (polar pt (* pi 1.5) gap))
        (setq str_text (strcat (itoa pline_num) "-" (itoa (setq cnt (1+ cnt)))))
        (vlax-invoke acsp 'insertblock pt "tick" 1 1 1 ang)
        (vlax-invoke acsp 'addtext str_text txtpt txt_height))
     pt_list)
     
        (initget 1 "Yes No")
              (setq acpt (getkword "\nDo you want to write points to file ? [Yes/No] <Yes>: "))
              (if (eq acpt "Yes")
         (progn
      (setq filename (strcat (getvar "dwgprefix")
            (vl-filename-base (getvar "dwgname"))".csv")
     )
      (setq datafile (open filename "a"))
     
           (setq i 1)
     
           (foreach pt pt_list
     
      (write-line (strcat (strcat (itoa pline_num) "-" (itoa i))
            (chr 9);<--tab delimited, (chr 44) - comma delimited
            (rtos (car pt)2 3);<--precision 3 decimals
            (chr 9);<--tab delimited, (chr 44) - comma delimited
            (rtos (cadr pt) 2 3)
            (chr 9);<--tab delimited, (chr 44) - comma delimited
            (rtos (caddr pt)2 3))
       datafile)
          (setq i (1+ i))
      )
           (close datafile)
      )
         )
    (princ)
      )
    ~'J'~
    Last edited by fixo; 21st Jun 2011 at 09:11 am. Reason: last coordinate: (rtos (caddr pt)2 3))
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

Similar Threads

  1. Extract Coordinates along polyline.
    By therock005 in forum AutoCAD General
    Replies: 27
    Last Post: 6th Feb 2013, 03:59 pm
  2. how to divide an ellipse in equal segments?
    By pvd in forum Autodesk Inventor
    Replies: 2
    Last Post: 10th Apr 2010, 07:51 am
  3. How to divide a line/polyline/3dpoly in equal no of parts using VBA
    By gogi07 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 5th Sep 2009, 11:12 am
  4. Divide equally less than or equal to 1500
    By EzyG in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 20th Jul 2009, 10:57 pm
  5. Can you automatically divide a line up into equal parts?
    By Tempest in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 22nd Nov 2007, 11:56 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