Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

XY coordinates from a polyline 3

Status
Not open for further replies.

Fuli129

Civil/Environmental
Aug 1, 2007
4
Is there a easy way to extract the X,Y, coordinates from a polyline? Right now, i have to convert it into a dxf, and then import it into another program to get the X, Y. I was wondering if anyone has a quicker way to achieve this outcome? Any help is much appreciated.
 
Replies continue below

Recommended for you

Nice little tool. Okay, I'll greadily ask somebody with a bit more lisp knowledge than myself. How would you modify the routine so that you could get the x,y coordinates while in a user-specificed coordinate system. This routine only spits out points referenced to the WCS.

Thanks!
 
Thanks for the replies. But I am looking for a little more also, just like epongra2. My cadd drawings are usually in a state plane coordinate system, and i need to extract out the X,Ys.
 
OK here's the requested routine, it took just 2 little edits to have it use current UCS coordinates. Enjoy, & report any problems :)

Code:
; ----------------------------------------------------------------------
;             (Export LWPOLYLINE Vertices & Points to File)
;            Copyright (C) 2000 DotSoft, All Rights Reserved
;                   Website: [URL unfurl="true"]http://www.dotsoft.com[/URL]
; ----------------------------------------------------------------------
; DISCLAIMER:  DotSoft Disclaims any and all liability for any damages
; arising out of the use or operation, or inability to use the software.
; FURTHERMORE, User agrees to hold DotSoft harmless from such claims.
; DotSoft makes no warranty, either expressed or implied, as to the
; fitness of this product for a particular purpose.  All materials are
; to be considered ‘as-is’, and use of this software should be
; considered as AT YOUR OWN RISK.
; ----------------------------------------------------------------------
;;Revised 8/23/07 CAB to report coordinates in current UCS
(defun c:ptexport ()
  (setq sset (ssget '((-4 . "<OR")(0 . "POINT")
                      (0 . "LWPOLYLINE")(-4 . "OR>"))))
  (if sset
    (progn
      (setq itm 0 num (sslength sset))
      (setq fn (getfiled "Point Export File" "" "txt" 1))
      (if (/= fn nil)
        (progn
          (setq fh (open fn "w"))
          (while (< itm num)
            (setq hnd (ssname sset itm))
            (setq ent (entget hnd))
            (setq obj (cdr (assoc 0 ent)))
            (cond
              ((= obj "POINT")
                (setq pnt (cdr (assoc 10 ent)))
                (setq pnt (trans pnt 0 1));;**CAB
                (princ (strcat (rtos (car pnt) 2 8) ","
                               (rtos (cadr pnt) 2 8) ","
                               (rtos (caddr pnt) 2 8)) fh)
                (princ "\n" fh)
              )
              ((= obj "LWPOLYLINE")
                (if (= (cdr (assoc 38 ent)) nil)
                  (setq elv 0.0)
                  (setq elv (cdr (assoc 38 ent)))
                )
                (foreach rec ent
                  (if (= (car rec) 10)
                    (progn
                      (setq pnt (cdr rec))
                      (setq pnt (trans pnt 0 1));;**CAB
                      (princ (strcat (rtos (car pnt) 2 8) ","
                                     (rtos (cadr pnt) 2 8) ","
                                     (rtos elv 2 8)) fh)
                      (princ "\n" fh)
                    )
                  )
                )
              )
              (t nil)
            )
            (setq itm (1+ itm))
          )
          (close fh)
        )
      )
    )
  )
  (princ)
)

(princ "\nPoint Export loaded, type PTEXPORT to run.")
(princ)
 
Carl,

Thanks! This routine will help with my slope stability analyses.
 
Well, instead of the LSP routine, I would place my UCS at the start of the polyline or any other reference point ,then do a LIST and check out the history(F2) giving you the X & Y values.
 
Thanks again for the replies, I know this might be a dumb question, but I am new to AutoCad, I normally work with ArcGIS. How do I add in that routine and get it to run. I know how the Visual Basic Editor works in ArcGIS, and i tried bringing in the routine, but not having any success with getting it to run. Maybe, i am not putting it in the correct location. Any help is much appreciated. Sorry again for the inexperienced questions.
 
Copy/paste the code into Notepad and save as PtExport.lsp (save it in a folder in acad's support path, e.g. \Support). Use Appload to load the app; type Ptexport at the command line to invoke the command.

____________________
Acad2006, Terramodel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor