×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

XY coordinates from a polyline
3

XY coordinates from a polyline

XY coordinates from a polyline

(OP)
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.

RE: XY coordinates from a polyline

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!

RE: XY coordinates from a polyline

(OP)
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.

RE: XY coordinates from a polyline

3

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: http://www.dotsoft.com
; ----------------------------------------------------------------------
; 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)

RE: XY coordinates from a polyline

Carl,

Thanks!  This routine will help with my slope stability analyses.

RE: XY coordinates from a polyline

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.

RE: XY coordinates from a polyline

(OP)
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.

RE: XY coordinates from a polyline

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources