Jump to content

Recommended Posts

Posted

Hello guys,

 

First I would like to thank you for this very useful forum. You've been helping me a lot.

 

But now I need a lisp that export the measure of each polyline's segment to excel. Something like the picture attached.

 

measure each segment csv.jpg

 

Thanks! :)

Posted

I've found there, but that routine has more than what I want.

 

I'd like one with just the Length of the segment. And, if possible, something that can select more polylines for the table, like the image attached before.

Posted

You want to export these segments' values or to select polylines and export each segment alone in a separate cell as shown in the Excel sheet ?

 

What about that L1 and L2 ? are they already existed or you want to name the exported polylines to have a reference of each row of value

to its polyline ?

Posted
You want to export these segments' values or to select polylines and export each segment alone in a separate cell as shown in the Excel sheet ?

 

What about that L1 and L2 ? are they already existed or you want to name the exported polylines to have a reference of each row of value

to its polyline ?

 

I want with each segment alone, like the Excel sheet.

 

About the L1 and L2, they are just an example. For what I need, can be just a numeration in the order of each polyline selected, starting with 1.

Posted

Give this a shot and let me know .

 

(defun c:Test (/ *error* ss f o i l n in sn lst a d st)
;;;	Author : Tharwat 16.Dec.2014	;;;
;;; Write Polylines' segments to Excel	;;;
;;;					;;;
 (defun *error* (x)
   (if o
     (close o)
   )
 )
 (princ "\n Select Polyline :")
 (if (and (setq ss (ssget '((0 . "LWPOLYLINE"))))
          (setq f (getfiled "\n Save as :" (getvar 'DWGPREFIX) "csv" 1))
     )
   (progn
     (setq o (open f "w")
           i 0
           l 0.
           n 0
     )
     (write-line "Ref No." o)
     (repeat (setq in (sslength ss))
       (repeat (fix (vlax-curve-getendparam
                      (setq sn (ssname ss (setq in (1- in))))
                    )
               )
         (setq d (vlax-curve-getdistatparam sn (setq i (1+ i))))
         (if (< 0. l)
           (setq lst (cons (setq a (- d l)) lst))
           (setq lst (cons d lst))
         )
         (if a
           (setq l (+ l a))
           (setq l (+ l d))
         )
       )
       (entmake (list '(0 . "TEXT")
                      (setq st (assoc 10 (entget sn)))
                      (cons 11 (cdr st))
                      (cons 40 (getvar 'TEXTSIZE))
                      (cons 1 (itoa (setq n (1+ n))))
                      (cons 7 (getvar 'TEXTSTYLE))
                )
       )
       (write-line
         (apply 'strcat
                (mapcar '(lambda (x) (strcat (rtos x 2 2) ";"))
                        (append (list n) lst)
                )
         )
         o
       )
       (setq lst nil
             i   0
             l   0.
       )
     )
     (close o)
   )
 )
 (princ)
)(vl-load-com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...