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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone know how to export data "xyz co ordinates"

Status
Not open for further replies.

jreinhart

Technical User
May 30, 2003
7
AU
I would like to export the xyz coordinates of an autocad drawing for use in an excel spreadsheet. I have been trying to figure this out for some time now but I need to figure this out as soon as possible. Please if anyone knows anything I would greatly appreciate any advice.
 
Do you want all xyz values of selected objects, just particular entity types, or points that you select? My experience is limited to points and blocks, and by use of a lisp routine writing the information to an ASCII file. This can then be pasted into Excel. There are ways of transferring information directly from AutoCAD to Excel using Visual Lisp/Active X that others may be able to comment on.
 
I want to export all of the xyz values. I have used a faro arm to make a cad drawing of a few parts that are going to be put into an agressive environment. I want to export all the xyz data for each part into excel for future analysis.

FYI: I want to get all the xyz points from the cad drawing for which I will use down the road as a baseline for comparing the parts changing dimensions.
 
Maybe this will lead you in the right direction. This routine creates a .txt file of your picked points. Then Excel > Open > All file types, then open the .txt you created. A "Text Import Wizard" pops up, and choose "delimited" in the radial button, then "Finish". There may be faster ways, but try this out.
Code:
;|		
			write2file.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;\nTo use, enter w2f at the command line.&quot;)
(princ)

P.S.: If you can't find where it is saving the text file, right-click your ACAD icon on your desktop > properties > shortcut > start in:
This will give you the file location.

Flores
 
newbiewonkinobie,

Thanks for your reply. What do I do with the routine? I know what to do once the file is created as a text file, but I dont know what to do with the routine.
 
Forget it!

I figured out how to get the routine working in cad. Now I just have to figure out how to select and export the points.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top