NanGlase Posted January 4, 2025 Posted January 4, 2025 (edited) Need help. how to maintain 3 decimal places even with zeros like in the picture? (defun c:nanpt () (vl-load-com) (princ "\nStakeout Point by: Nan Glase (2024-12-24)") (princ "\nEnter \"NANPT\" to run.") (setq points '()) (setq polyline nil) ; Variable to hold the polyline object ;; Start the polyline command (command "_.PLINE") (while t (setq pt (getpoint "\nSelect a point (or press Enter to finish): ")) (if (null pt) (progn ;; Finish the polyline if at least one point was selected (if (> (length points) 0) (progn (command "") ; End the polyline command (setq polyline (entlast)) ; Get the last entity created (the polyline) ;; Save points to a file (setq data '()) (setq i 1) (foreach p points (setq line (strcat "S" (itoa i) ", " (rtos (cadr p) 2 3) ", " (rtos (car p) 2 3) ", 0")) (setq data (append data (list line))) (setq i (1+ i)) ) (setq formattedData (apply 'strcat (mapcar (function (lambda (x) (strcat x "\n"))) data))) (setq tmpfile (vl-file-syst-write (strcat (getenv "TEMP") "\\Nan_stakeoutpoint.txt") formattedData)) (startapp "notepad.exe" tmpfile) ) (princ "\nPlease select at least one point before finishing.") ) (if polyline (progn (command "_.ERASE" polyline "") ; Erase the polyline (setq polyline nil) ; Clear polyline reference ) ) (setq points nil) ; Clear points list ) (progn ;; Append the point to the list (setq points (append points (list pt))) ; Store the point directly (command pt) ; Add the point to the polyline ) ) ) (princ) ) (defun vl-file-syst-write (filename content) (setq file (open filename "w")) (if file (progn (write-line content file) (close file) (princ (strcat "\nData has been written to Notepad. " filename)) ) (princ "\nError opening file for writing.") ) filename ) (princ "\nStakeout Point by: Nan Glase (2024-12-31)") (princ "\nEnter \"NANPT\" to run.") Edited January 5, 2025 by NanGlase Added Code Tags! Quote
Lee Mac Posted January 4, 2025 Posted January 4, 2025 (edited) Set DIMZIN to 0 before using rtos and then restore its original value. Edited January 4, 2025 by Lee Mac 1 Quote
SLW210 Posted January 5, 2025 Posted January 5, 2025 Please place code in code tags! (<> in the editor toolbar) 1 Quote
NanGlase Posted January 6, 2025 Author Posted January 6, 2025 my bad. what do you mean? im new at coding. Quote
NanGlase Posted January 6, 2025 Author Posted January 6, 2025 On 1/5/2025 at 12:50 AM, Lee Mac said: Set DIMZIN to 0 before using rtos and then restore its original value. thank you! Quote
SLW210 Posted January 6, 2025 Posted January 6, 2025 8 hours ago, NanGlase said: my bad. what do you mean? im new at coding. Select the <> in the editor and place your code in the code box that pops up. 1 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.