Jump to content

The never ending story: Polyline export to file


Recommended Posts

Posted (edited)
(defun c:vlplexport  (/ AT:GetVertices strnum theobj fn)
     (defun AT:GetVertices  (e / p l)
           ;; Return point at each vertex of curve
           ;; e - curve to evaluate (Arc, Line, *Polyline, Spline)
           ;; Alan J. Thompson, 09.30.10
           (if e
                 (if (eq (setq p (vlax-curve-getEndParam e))
                         (fix p))
                       (repeat (setq p (1+ (fix p)))
                             (setq l    (cons (vlax-curve-getPointAtParam
                                                    e
                                                    (setq p    (1- p)))
                                              l))
                             )
                       (list (vlax-curve-getStartPoint e)
                             (vlax-curve-getEndPoint e))
                       )
                 )
           )
     (defun strnum  (str val / p)
           (setq p " ")
           (repeat (- val (strlen str))
                 (setq p (strcat " " p)))
           (strcat str p))
     (vl-mkdir "c:/autolisp")
     (prompt "\nSelect a Polyline: ")
     (while (setq theobj (ssget ":S:E" '((0 . "*LINE"))))
           (setq thelist (AT:GetVertices (setq e (ssname theobj 0))))
           (setq fn (open "c:/autolisp/infile.txt" "w"))


           (redraw e 3)
           (foreach
                  itm  thelist
                 (write-line
                       (strcat "          at point  X ="
                               (strnum (rtos (Car itm) 2 4) 10)
                               "Y= "
                               (strnum (rtos (Cadr itm) 2 4) 10)
                               "Z= "
                               (strnum (rtos (last itm) 2 4) 10))
                       fn)
                 )
           (close fn)
           )(vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
     (princ)
     )

Edited by SolarPVDesigner
  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    15

  • elfert

    11

  • Kapanther

    8

  • SolarPVDesigner

    4

Posted (edited)

Where would the following code be incorporated into the code above?

 

(setq _trans (lambda (pt) (trans pt 0 1)))

(setq ss (AT:GetVertices (car (entsel))))
(setq pts (mapcar '_trans ss));<-- translated point list

Once I see it done I can grasp it and then look out world!!

 

Thanks pBe and Lee Mac

 

Thanks,

Edited by SolarPVDesigner
Posted

SolarPVDesigner,

 

Have a read of the Code Posting Guidlines for information on how to format code in your posts.

 

Also, looking at the code you have posted, are you aware that this will overwrite the export file for each Polyline selected? Is this your intention?

 

Lee

Posted

Lee Mac,

 

I will follow the Guidelines from here on out.

 

And Yes I want to overwrite the export file.

 

John

Posted

(setq fn (open "c:/autolisp/infile.txt" "w")) and (close fn);

Posted
Where would the following code be incorporated into the code above?

 

Once I see it done I can grasp it and then look out world!!

 

Thanks pBe and Lee Mac

 

Thanks,

 

(setq thelist
               [color=blue][b](mapcar
                   (function (lambda ( j) (trans j 0 e)))
[/b][/color]                    (AT:GetVertices (setq e (ssname theobj 0)))
               [color=blue][b])
[/b][/color]            )

 

HTH

  • 10 years later...
Posted

After export Polylines to file, could I import that file to other drawing with nothing change (include Spline or Arc segments, Layer, color...)? It is like Copy and Paste to Original Coordinates, but instead open DWG file and copy, I can choose that TXT file.

Thank you.

Posted
13 hours ago, saunambon654 said:

After export Polylines to file, could I import that file to other drawing with nothing change (include Spline or Arc segments, Layer, color...)? It is like Copy and Paste to Original Coordinates, but instead open DWG file and copy, I can choose that TXT file.

Thank you.

As to not dig at all the topic , would you please, upload all dwg, lsp , and text or csv files?

Posted

Using Wblock much easier way to approach this request, all dwg object properties are maintained.

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