Jump to content

Export xyz coordinate to specified csv file


barristann

Recommended Posts

Hi all,

I need a lisp command that, as I click on 3D Point(s), the xyz coordinate will be exported or concatenated to "C:\Users\John\Desktop\PData\Coord.csv"

 

I've searched for hours & found similar, but I don't know how to export to the same folder & csv file every time (I'm new to lisp).

https://www.cadtutor.net/forum/topic/54721-export-data-point-to-excel-file/

 

Thank you

 

Link to comment
Share on other sites

So what do you have so far? 

 

First part - getting the coordinate, can you get that OK

Second part, 'fixing' the coordinate, how do you want this to be in the CSV file? For example if viewed in a spreadsheet, all coordinates in 1 cell [x,y,z] or in 3 cells in the row [x] [y] [z] ?

Other second part have you fixed the coordinate to suit? This will need to be a text string, comma separated for each 'cell' in the row

 

Then all it comes to is writing or appending to a text file (as far as LISP is concerned a CSV file is a text file with a CSV extension.

So how much help do you want with this? I can say how I would do it and see how far you'd get?

- set a variable with the file path, since it is a string the '\' will need to be doubled to '\\' (lisp sees \ as a marker for a special character, so need to add a second ''\') (easier to have this near the beginning of the LISP so it is easier to spot and consistent through the LISP)

- Look here for a simple example to create or write to a text file, the last post from Lee Mac: 

 - and if you get really clever put the write to file as a separate LISP, sending the file path and name, and the text to append, saved away you can use this again and again whenever you want to write to any text file

 

 

 

And then wrote back if you get stuck?

 

 

 

Link to comment
Share on other sites

Hi Steven.

 

I would like all coordinates in 1 cell [x,y,z]

 

I have just discovered lisp a month ago. So I have no clue what to do.

Link to comment
Share on other sites

When you write to a file you have 2 options "W" or "A" Write or Append, the write option will start as a new file, the append will add on. But be careful if you use 1 name and append it may already have data. Hint vla-delete-file

 

(setq fo (open "d:\\mystuff\\thefile.csv" "A"))

 

Like steven "So how much help do you want with this? I can say how I would do it and see how far you'd get?"

 

Oh yeah if pick pick pick no need to append, use "W"as you do the pick inside a loop and write out the answer each time.

 

Edited by BIGAL
Link to comment
Share on other sites

4 hours ago, barristann said:

Thank you for your guidance guys. I'll try my best with trial and error since I'm an amateur at best.

 

That's the best way, ask when you get stuck and the help will often be better. Let us know how you get on!

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