Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Lisp Routine

Status
Not open for further replies.

una2002

Technical User
Joined
Jan 24, 2002
Messages
2
Location
IE
Hi

I am setting out a large construction project, giving x and y co-Cordinates, does any body know of a lisp routine that extracts these co-cordinates into an excel file. Any help would be grateful.

Thanks
 
You might try a search at What form are the coordinates -text numbers, attributes, etc? If you have points inserted at these coordinates, it would be a fairly simple lisp to extract the x-y values and write them to a text file. This file, in csv format, could then be opened in Excel.
 
Here is a routine that extracts picked points. The output file is in the ".txt" file format, but just open this in Excel and the text-import wizard will start up.

Code:
;|		
			write_to_file.LSP
 A routine to write picked points to an external file

|;

(defun C:w2f ()
  (graphscr)
  (setq FNM (getstring "Enter name of text file to create: "))
  (setq FNM (strcat FNM ".txt"))
  (setq FD (open FNM "w"))
  (setq HEAD "POINT \t\tX \t\tY  \t\tZ")
  (write-line "Exported coordinates:-" FD)
  (princ "\n" FD)
  (write-line HEAD FD)
  (princ "\n" FD)
  (initget 1)
  (setq N1 (getint "\nEnter number of points to export: "))
  (if (Null PN)
    (setq PN 1)
  )
  (prompt &quot;\nEnter first point reference number <&quot;)
  (princ PN)
  (setq PNN (getint &quot;>: &quot;))
  (if (Null PNN)
    (setq PN PN)
    (setq PN PNN)
  )
  (repeat N1
    (initget 3)
    (setq P1 (getpoint &quot;\nPick point to export: &quot;))
    (setq PX1 (car P1))
    (setq PX1 (rtos PX1 2 3))
    (setq PY1 (cadr P1))
    (setq PY1 (rtos PY1 2 3))
    (setq PZ1 (caddr P1))
    (setq PZ1 (rtos PZ1 2 3))
    (princ PN FD)
    (princ &quot;\t\t&quot; FD)
    (princ PX1 FD)
    (princ &quot;\t&quot; FD)
    (princ &quot;\t&quot; FD)
    (princ PY1 FD)
    (princ &quot;\t&quot; FD)
    (princ &quot;\t&quot; FD)
    (princ PZ1 FD)
    (princ &quot;\n&quot; FD)
    (setq PN (1+ PN))
  )
  (close FD)
  (setq PN nil)
  (princ)
)(prompt &quot;To use, enter w2f at the command line.&quot;)
(princ)

Flores
 
Thanks newbiewonkinobie,

Tried it, and it works like a dream and saved me a lot of work.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top