KerrCAD Posted January 19 Posted January 19 Am writing lsp code to process lat/lng data points. The source program writes out to xlsx. When I read in the file (many thanks to Shadi - see link below) it rounds/truncates the lat/lng data to 4 decimal places. I'd like to get as much precision as possible. Can anyone help me through this? Shadi's code starts with this: (vlax-get-object "Excel.Application.16") and reads the entire file to a list quite quickly. But I cannot find a way around the 4 decimal limit read into AutoCAD. Many Thanks! Excel source data: Lisp result (with job name deleted): Quote
pkenewell Posted January 22 Posted January 22 @KerrCAD How are we going to know what's going on if you haven't shared your code, or at least the part you are concerned with? The original Shadi.lsp READS from excel and writes text. If yours is doing the opposite, you have to look at how you are retrieving and formatting the data and putting it back into Excel. Without seeing any code, I would say the solution is - after you get your Long and Lat value real numbers, convert them to a string using (rtos VAL 2 8), where "8" is the number of decimal precision you want. Then send them to Excel. Quote
Steven P Posted January 22 Posted January 22 I couldn't find the link just then, but if he is lurking behind the scenes tonight, I am sure Lee Mac posted once about long or floating point decimal places - you might be in luck and he remembers what he wrote. Might not be in luck. Quote
pkenewell Posted January 22 Posted January 22 (edited) @Steven P Is this what your talking about? Maybe not what you meant. Agreed however, this would be a good idea to use, rather then just plain (rtos). https://www.lee-mac.com/consistentrtos.html Edited January 22 by pkenewell Quote
KerrCAD Posted January 22 Author Posted January 22 6 hours ago, pkenewell said: @KerrCAD How are we going to know what's going on if you haven't shared your code, or at least the part you are concerned with? The original Shadi.lsp READS from excel and writes text. If yours is doing the opposite, you have to look at how you are retrieving and formatting the data and putting it back into Excel. Without seeing any code, I would say the solution is - after you get your Long and Lat value real numbers, convert them to a string using (rtos VAL 2 8), where "8" is the number of decimal precision you want. Then send them to Excel. Fair enough. Attached is the slightly modified version of Shadi's code. It serves as a function that returns a list of lists. "ReadExcel" on the command line to execute. Also attached is a small excel file for testing. DGK_Shadi.lsp DGK_Shadi.xlsx Quote
KerrCAD Posted January 22 Author Posted January 22 (edited) Also, I did not explain that the application that writes the xlsx file to be read by AutoCAD is not AutoCAD. It is GPS software from another party. It writes out 13(?) decimals to the xlsx file, but I cannot get AutoCAD to read in more than 4 decimal places. Now I am wondering. I only looked at the number of decimal places in the AutoCAD vlisp editor and on the command line. Turns out I'm an idiot. If I do (RTOS Lat 2 13) of the latitude read in by AutoCAD, all the decimal digits are there. AutoCAD only returns the 1st four to the display. Having started lisp at v10 286, I'm pretty embarrassed to admit how many years I've know this. My sincere apologies for wasting your collective time. Edited January 22 by KerrCAD 1 Quote
Steven P Posted January 22 Posted January 22 That's no problem - we all do silly things every now and then 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.