Jump to content

Midpoint of a line Export to CSV


ktbjx

Recommended Posts

i have a list here that exports XYZ Length Angle

But now i want to export only the MidPoint of every Line, can someone Help Me?

 

(defun c:LINEEXTRACTION ( / d e f i s spt ept)
   (if (and (setq s (ssget '((0 . "LINE"))))
            (setq f (getfiled "" "" "CSV" 1))
            (setq d (open f "w"))
       )
       (progn
           (write-line "Start X,Start Y,Start Z,End X,End Y, End Z,Group,Length,Angle" d)
           (repeat (setq i (sslength s))
               (setq e (entget (ssname s (setq i (1- i))))
spt (cdr (assoc 10 e))
ept (cdr (assoc 11 e))
)
               (write-line
                   (LM:lst->str
                       (append
                           (mapcar 'rtos (cdr (assoc 10 e)))
                           (mapcar 'rtos (cdr (assoc 11 e)))
                           (if (and (setq e (member '(102 . "{ACAD_REACTORS") e))
                           (setq e (member '(102 . "{ACAD_REACTORS") (entget (setq x (cdr (assoc 330 e))))))
                        (setq e (cdr (assoc 3 (member (cons 350 x) (reverse (entget (cdr (assoc 330 e))))))))
                       )
                           (list e)
                   )
                       )
                       ","
                   )
                   d
               )
           )
           (close d)
       )
   )

(prompt "DONE!")
(princ)
)

(defun LM:lst->str ( lst del )
   (if (cdr lst)
       (strcat (car lst) del (LM:lst->str (cdr lst) del)
       ","
   (rtos (distance spt ept)) ","
       (angtos  (angle spt ept))
       )                    
       (car lst)
   )
)
   (princ)

Link to comment
Share on other sites

ktbjx no offence but you have all the answers in front of you, have a go at doing it, you have pt1 xyz pt2 xzy the 3d mid pt is just simple maths MidX=(pt1x+pt2x)/2 and so on.

 

Big hint

spt (cdr (assoc 10 e))

ept (cdr (assoc 11 e))

further delving

x = car y=cadr z=caddr

Link to comment
Share on other sites

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...