Jump to content

HOw to Export GPS Coordinates to CSV


wajidgates

Recommended Posts

Dear All,

 

Good Day,

 

I am looking for a method to export all the GPS coordinates which have been assigned to each point along with the properties of that point to an excel csv.

In our drawings, there are multiple columns and each column has four points and each point has X,Y,Z coordinates. I want to export all this information to an excel sheet.

 

Any idea?

 

Thank You

Link to comment
Share on other sites

Try this :-

 

(Defun C:ExportPMT (/ *error* Smode file dta i theEntity eb pnt    txv)

 (setvar "cmdecho" 0)

 (Defun *error* (msg)
   (if    (not (member msg
            '("bad argument type: lselsetp nil"
              "bad argument type: stringp nil"
              "quit / exit abort"
              "Function cancelled"
             )
        )
   )
     (princ (strcat "\nError: " msg))
   )
   (princ)
   (prompt
     "\n........................................................"
   )
   (princ "\nStatus : Function cancelled")
 )

 (prompt
   (strcat "\n:: Routine created by Satish Rajdev. ::")
 )

 (initget 1 "P T")
 (setq Smode (getkword "\nSelect Mode ('P'Point/'T'Text or Mtext):"))

 (setq
   file (open (getfiled "Specify Output XYZ File" "c:/" "CSV" 1)
          "w"
    )
 )

 (if (= Smode "P")
   (progn
     (write-line
   "Easting (mE),Northing (mN),Elevation (m)"
   file
     )
     (while (= dta nil)
   (setq dta (ssget '((0 . "POINT")))
   )
   (if (= dta nil)
     (alert "Please select POINTS to continue...")
   )
     )
     (repeat (setq i (sslength dta))
   (setq theEntity (ssname dta (setq i (1- i))))
   (setq eb (entget theEntity))
   (setq pnt (cdr (assoc 10 eb)))
   (setq txv (rtos (caddr pnt) 2 3))
   (write-line
     (strcat (rtos (car pnt) 2 3)
         ","
         (rtos (cadr pnt) 2 3)
         ","
         txv
     )
     file
   )
     )
     (close file)
     (setq msg "CSV File is created with extracted POINT details")
     (alert msg)
   )
 )

 (if (= Smode "T")
   (progn
     (write-line
   "Easting (mE),Northing (mN),Text Value"
   file
     )
     (while (= dta nil)
   (setq dta (ssget '((0 . "TEXT,MTEXT")))
   )
   (if (= dta nil)
     (alert "Please select Text/Mtext to continue...")
   )
     )
     (repeat (setq i (sslength dta))
   (setq theEntity (ssname dta (setq i (1- i))))
   (setq eb (entget theEntity))
   (setq pnt (cdr (assoc 10 eb)))
   (setq txv (cdr (assoc 1 eb)))
   (write-line
     (strcat (rtos (car pnt) 2 3)
         ","
         (rtos (cadr pnt) 2 3)
         ","
         txv
     )
     file
   )
     )
     (close file)
     (setq msg "XYZ File is created with extracted TEXT/MTEXT details")
     (alert msg)
   )
 )

 (prompt
   "\n........................................................"
 )
 (prompt (strcat "\nStatus : " msg))
 (setq *error* nil)
 (setvar "cmdecho" 1)
 (princ)
)

(princ)
(princ
 "\n:: Type \"ExportPMT\" to Run the Routine ::"
)
(princ)

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