Jump to content

How to read polyline vert to file with name?


iztok13

Recommended Posts

If the notepad file: "Desired" is indeed what you would like:

 

;|

   Polyline Coordinate Writer

       by Lee McDonnell

         27.01.2009

|;

; Version 2 ~ Polyline Writing Format Altered.


(defun c:plco2 (/ File oFile ss eLst Selss pName aEnt vLst i vNme)
 (vl-load-com)
 (if (setq File (getfiled "Create a Text File" "C:\\" "txt" 9))
   (progn
     (setq oFile (open File "W"))
     (if (setq    ss (ssget (list    (cons 0 "POLYLINE")
   (if (getvar "CTAB") (cons 410 (getvar "CTAB"))(cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq    eLst  (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
       Selss (ssadd))
     (foreach ent eLst
       (ssadd ent Selss)
       (sssetfirst nil Selss)
       (if    (not (setq pName (getstring t "\nSpecify Name for Selected Polyline >  ")))
         (setq pName (vl-princ-to-string ent)))
       (setq aEnt (entnext ent))
       (while (/= "SEQEND" (cdr (assoc 0 (entget aEnt))))
         (setq vLst (cons (cdr (assoc 10 (entget aEnt))) vLst)
           aEnt (entnext aEnt)))
       (setq i    (length vLst))
       (while (not (minusp (setq i (1- i))))
         (write-line
       (strcat    pName "\t"
           (rtos (car (nth i vLst)) 2 2) ","
           (rtos (cadr (nth i vLst)) 2 2) ","
           (rtos (caddr (nth i vLst)) 2 2) "\n") oFile))
       (setq vLst nil)
       (ssdel ent Selss)
       (sssetfirst nil nil)))
   (princ "\n<!> No Polyline Selected <!>")))
   (princ "\n<!> No File Selected <!>"))
 (close oFile)
 (princ "\n...Vertices Written to File...")
 (princ))

 

Then the above should do your bidding. :)

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    17

  • iztok13

    10

  • CarlB

    1

ok the the desire file is ok, But when i run plco2 lisp writen above i cant select poly, it say nothing selected????

 

please try the file wich i upload and try if you have the same problem?

Link to comment
Share on other sites

Here you are - just window the whole drawing to select polylines (as in your example).

 

;|

   Polyline Coordinate Writer

       by Lee McDonnell

         27.01.2009

|;

; Modified for use with LWPOLYLINES


(defun c:plco2 (/ File oFile ss eLst Selss pName aEnt vLst i)
 (vl-load-com)
 (if (setq File (getfiled "Create a Text File" "C:\\" "txt" 9))
   (progn
     (setq oFile (open File "W"))
     (if (setq    ss (ssget (list    (cons 0 "LWPOLYLINE")
   (if (getvar "CTAB") (cons 410 (getvar "CTAB"))(cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq    eLst  (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
       Selss (ssadd))
     (foreach ent eLst
       (ssadd ent Selss)
       (sssetfirst nil Selss)
       (if    (not (setq pName (getstring t "\nSpecify Name for Selected Polyline >  ")))
         (setq pName (vl-princ-to-string ent)))
       (setq vLst (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget ent))))
       (setq i    (length vLst))
       (while (not (minusp (setq i (1- i))))
         (write-line
       (strcat    pName "\t"
           (rtos (car (nth i vLst)) 2 2) ","
           (rtos (cadr (nth i vLst)) 2 2) "\n") oFile))
       (setq vLst nil)
       (ssdel ent Selss)
       (sssetfirst nil nil)))
   (princ "\n<!> No Polyline Selected <!>")))
   (princ "\n<!> No File Selected <!>"))
 (close oFile)
 (princ "\n...Vertices Written to File...")
 (princ))


Link to comment
Share on other sites

Ok I tested, This time I think it really works for me. im really glad that you help me. This routin will make my work much easier than time before.

Thank you again.

 

:)

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