Jump to content

The never ending story: Polyline export to file


Recommended Posts

Posted (edited)

Thx pBE. Does this mean that this routine that you wrote can be used with line, poly line, lw poly lines and 3D polyline, very nice that is exactly what i need?

 

Please if you can do a ;; around the lisp i could lean something. But i must say many thanks what you have done so far.

 

I still need the file to be "W" rite so no append to the file.

 

And another thing is that when i make a selection of Lines let we say 3 lines i need the coordinates in this manor to the file:

 

S X= Y= Z=

E X= Y= Z=

S X= Y= Z=

E X= Y= Z=

S X= Y= Z=

E X= Y= Z=

 

The way that you have done it with the poly lines, LW poly lines,3d poly lines ect. i just grate, But when it is lines that is selected the output to the file should be like the one mentioned over here.

Edited by elfert
  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    15

  • elfert

    11

  • Kapanther

    8

  • SolarPVDesigner

    4

  • 2 months later...
Posted

How can I add a column to include an "identifier" for which polyline the x,y coord comes from?

 

Fox example? could you add a column for the acad handle maybe? or a "count" as it moves through each polyline?

 

Thanks for your help!

Posted (edited)

Yes YOU can :)

 

This code feels like ages ago. I need to have look-see at the code i posted

 

Hang on....

Edited by pBe
Posted

Indeed.. Thanks for your help!

Posted

Will it look like this for every line?

 
[color=blue][b]B49F[/b][/color] at point X =14805.2190 Y= 4837.2547 Z= 0.0000
[color=blue][b]B49F [/b][/color]at point X =19030.0596 Y= 10922.8723 Z= 0.0000 

 

or

 
[b][color=blue]B49F[/color][/b] at point X =14805.2190 Y= 4837.2547 Z= 0.0000
[color=white]_____[/color][color=black]at point  X =19030.0596 Y= 10922.8723 Z= 0.0000 [/color]

Posted

B49F at point X =14805.2190 Y= 4837.2547 Z= 0.0000

B49F at point X =19030.0596 Y= 10922.8723 Z= 0.0000

 

is fine

 

B49F,14805.2190,4837.2547,0.0000

B49F,19030.0596,10922.8723,0.0000

 

is better

 

No need to stop the handle

 

sounds like oyu got it

Posted

Gimme Gimme Gimme!!! hehe :notworthy:

 

thanks for your help!!

Posted
Gimme Gimme Gimme!!! hehe :notworthy:

thanks for your help!!

 

Hold your horses Kapanther :).

You do realize that the code wirtes to a specific file on a specific folder and drive letter. Do you want to maintain that?

Posted

Hehe I can modify as necessary.

 

Thanks for help

Posted

You have me waiting in suspense!

Posted (edited)
Hehe I can modify as necessary.

 

Thanks for help

 

You can modify the rest then

 
(defun c:vlplexport  (/ AT:GetVertices  _dxf theobj[b][color=blue]s[/color][/b] [b][color=blue]i [/color][/b]fn thelist  f)
     (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 _dxf (ent dx)(cdr (assoc dx (entget ent))))
     (prompt "\nSelect a [b][color=blue]Polyline/Lines for data export[/color][/b]: ")
[color=blue][b](if (and[/b][/color] (setq theobjs (ssget  '((0 . "*LINE"))))
        (not (vl-mkdir "c:/User"))
        (setq fn (open (setq f "c:/user/infile.txt") "w"))[b][color=blue])[/color][/b]
   [color=blue][b](progn
        (repeat (setq i (sslength theobjs))
[/b][/color]     (setq thelist (if (eq (_dxf (setq e (ssname [color=blue][b]theobjs (setq i (1- i))[/b][/color])) 0) "LINE")
                        (list (cons (_dxf e 5)(_dxf e 10))
                              (cons (_dxf e 5)(_dxf e 11)))
       (mapcar '(lambda (j)(cons (_dxf e 5) j))
                                  (AT:GetVertices e))))                       
         (foreach 
                  itm  thelist
                 (write-line
                       (strcat (car itm) ","
                               (rtos (Cadr itm) 2 4)
                               ","
                               (rtos (Caddr itm) 2 4)
                               ","
                               (rtos (last itm) 2 4))
                       fn)
                 )
           )
     (close fn)
     (startapp "notepad" f)
        )[b][color=blue](princ "\nNo Entities to process")
   )[/color][/b]
     (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
           (princ)
     )

 

HTH

Edited by pBe
Updated for mulitple selection
Posted

So Kapanther, did it work for you? You have me waiting in suspense! :lol:

Posted

Yeah it worked!

 

Although I forgot this lisp only does it for one polyline. How hard is to do on multiple polylines?

 

?

Posted
Yeah it worked!

 

Although I forgot this lisp only does it for one polyline. How hard is to do on multiple polylines?

 

?

 

Its not really just for one polyline, as long as you keep selecting a valid entity (Line/Polyline/Lwpolyline) the program will continue. Also, take note that it overwrites the previous data whenever you run the program on another set of objects. the "W" argument for open does that.

Anyhoo. i updated the code for multiple selection mode.

 [/color][/b]
Posted

Nice work fella.

 

Works a treat!!!!!!

 

:)

 

I owe you one.!

Posted
Nice work fella.

Works a treat!!!!!!

I owe you one.!

 

Good for you Kapanther, The way i see it. you owe this forum more than you do me. ;)

 

Glad i could help, Cheers

Posted

I'm running the routine by Alan J. Thompson, 09.30.10 but I need it to follow my UCS. Right now it's only working off WCS. I'm getting back into AutoLISP after a 15 year hiatus and trying to determine if I can get the "Tran" command to work for this.

Posted
I'm running the routine by Alan J. Thompson, 09.30.10 but I need it to follow my UCS. Right now it's only working off WCS. I'm getting back into AutoLISP after a 15 year hiatus and trying to determine if I can get the "Tran" command to work for this.

 

Which code are you referring to SolarPVDesigner?

Posted (edited)

Guess he meant AT:GetVertices

 

No need to modify the function but instead apply trans on the result of the function

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

 

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

 

HTH

 

EDIT:Unless Alanjt decides to incorporate the trans within his sub ;)

Edited by pBe

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