defun C:PNT2FILE() (if(setq f(open "C:/test.txt" "w")) (write-line (getpoint "\nChoose Inspoint: ") f)) (close f) )
Above is my code as is now however it fails to record to the textfile could somboy elaborate
(defun c:CNT2FILE (/ f pt) (cond ((and (setq f (open "C:/test.txt" "w")) (setq pt (getpoint "\nPick point:")) (write-line (vl-string-trim "()" (vl-prin1-to-string pt)) f)))) (close f))
if you want mulitple points and
(defun c:CNT2FILE (/ f pt p2) (cond ((and (setq f (open "C:/test2.txt" "w")) (setq pt (getpoint "\nPick point:")) (while (setq pt2 (getpoint pt "\nChoose Inspoint: ") pt pt2) (write-line (vl-string-trim "()" (vl-prin1-to-string pt2)) f) ))) ) (close f))
@The_Caddie wrote:
defun C:PNT2FILE() (if(setq f(open "C:/test.txt" "w")) (write-line (getpoint "\nChoose Inspoint: ") f)) (close f) )Above is my code as is now however it fails to record to the textfile could somboy elaborate
The (write-line) function wants a text string to send, so it doesn't like a point list. If you don't mind having the parentheses included, you can simply change (write-line) to (princ), which has a send-it-to-a-file option, and doesn't require what you send to be a text string, so there's no conversion needed:
(defun C:PNT2FILE()
(if (setq f (open "C:/test.txt" "w"))
(princ (getpoint "\nChoose Inspoint: ") f)
)
(close f)
)
@Kent1Cooper wrote:If you don't mind having the parentheses included, ..Hence the conversion
But you are so right about "princ" (send ot a file option)
Thank you for that Kent