barristann Posted December 26, 2022 Posted December 26, 2022 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 Quote
Steven P Posted December 26, 2022 Posted December 26, 2022 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? Quote
barristann Posted December 26, 2022 Author Posted December 26, 2022 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. Quote
BIGAL Posted December 27, 2022 Posted December 27, 2022 (edited) 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 December 27, 2022 by BIGAL Quote
barristann Posted December 27, 2022 Author Posted December 27, 2022 Thank you for your guidance guys. I'll try my best with trial and error since I'm an amateur at best. 1 Quote
Steven P Posted December 27, 2022 Posted December 27, 2022 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! Quote
BIGAL Posted December 28, 2022 Posted December 28, 2022 If your sending to Excel, when you get more experienced we can show you how to write direct to excel filling in cells. Quote
Recommended Posts
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.