+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
  1. #11
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Jun 2011
    Posts
    2

    Default How to divide 3D Polyline in segments and export in formar txt or csv?

    Registered forum members do not see this ad.

    Dear Cad Tutor

    I'll really appreciate if you explain me how to divide a 3D polyline into "n" equal segments and export to a txt or cvs file.

    Thanks a lot.

  2. #12
    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,586

    Default

    Registered forum members do not see this ad.

    Try this code
    This will write all measured points include start and end points
    to csv file
    You'd be easily save it then as .xls
    Code:
     
     ;;write 3dpoly points to csv
     
    (defun C:pcd(/ cnt datafile dimz en ent num filename pline pt pt_list step 
    )
     
     
    (vl-load-com)
      (setq dimz (getvar "dimzin"))
      (setvar 
    "dimzin" 3);<-- change to suit
    (if (and
         (setq 
    num (getint "\n\tEnter a number of divisions: ")) 
    (setq ent (entsel 
    "\n\tSelect polyline >> "))
     (eq "POLYLINE"(cdr(assoc 0 (entget 
    (setq en(car ent)))))))
       (progn
         (setq 
    pt_list nil)
        (setq pline (vlax-ename->vla-object 
    en))
        (setq step (/ (vla-get-length pline ) num))
    (setq 
    pt_list nil)
    (setq pt_list (cons (vlax-curve-getstartpoint pline) 
    pt_list))
      (setq cnt 0)
      (repeat (1- 
    num)
        (setq  pt 
    (trans
     
    (vlax-curve-getPointAtDist pline  (* (setq  cnt (1+ cnt)) 
    step)
     
    )
              0 
    1
            )
     
    )
        (setq pt_list (cons pt pt_list))
      )
    (setq 
    pt_list (cons (vlax-curve-getendpoint pline) 
    pt_list))
     
    (setq pt_list (reverse 
    pt_list))
     
     
    (setq filename (strcat (getvar 
    "dwgprefix")
            (vl-filename-base 
    (getvar "dwgname"))".csv")
     )
      (setq datafile (open filename 
    "w"))
     
         (setq i 
    1)
     
           (foreach pt 
    pt_list
     
      (write-line (strcat (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)
      )
         )
    (setvar "dimzin" 
    dimz)
    (princ)
      )  
        (princ "\n\t===  
    Type PCD to execute  ===")
    (prin1)
    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