JuniorNogueira Posted July 18, 2018 Posted July 18, 2018 Hello everyone, everything good. First apologies for my pessimo ingles. (defun c:Test0008 (/ p1 oFile sFile tmp Separator i ;|Functions|; GetFormatFile aux:SelectFile grdx ) ;;_________________________________________________ (defun GetFormatFile (/ lsts) (or *Format* (setq *Format* "csv")) (setq lsts '(("csv" ";" "[<Csv>/Txt/Xls]") ("txt" " " "[Csv/<Txt>/Xls]") ("xls" "\t" "[Csv/Txt/<Xls>]"))) (setq mens (last (assoc *Format* lsts))) (initget "Csv Txt Xls _csv txt xls") (if (setq tmp (getkword (strcat "\nFormat file;" mens ": "))) (setq *Format* tmp) ) (setq Separator (cadr (assoc *Format* lsts))) ) ;;_________________________________________________ (defun aux:SelectFile ( Extension / ff) (if (setq ff (getfiled "Select File" (if *TmpRutaFile* *TmpRutaFile* "") Extension 1)) (setq *TmpRutaFile* (strcat (vl-filename-directory ff) "\\")) );c.if ff );c.defun ;;_________________________________________________ ; grdx - graphic cross utility (defun grdx (p col size / h) (setq h (/ (getvar "viewsize") size)) (grdraw (list (- (car p) h) (- (cadr p) h)) (list (+ (car p) h) (+ (cadr p) h)) col 0) (grdraw (list (- (car p) h) (+ (cadr p) h)) (list (+ (car p) h) (- (cadr p) h)) col 0) p );c.defun ;;--------------------- MAIN ----------------- (or *Prec* (setq *Prec* 4)) (setq p1 (getpoint "\nPick first point: ")) (while p1 (grdX p1 213 125) (setq lstFile (cons p1 lstFile)) (setq p1 (getpoint " >> Pick Next point: ")) ) (cond (lstFile (initget (+ 4)) (if (setq tmp (getint (strcat "\nPrecisión;<" (itoa *Prec*) ">: "))) (setq *Prec* tmp) ) (GetFormatFile) (setq sFile (aux:SelectFile *Format*)) (cond (sFile (setq i 1) (setq oFile (open sFile "w")) (write-line "COORDINATES OF POINTS" oFile) (write-line (strcat "#" Separator "X" Separator "Y" Separator "Z") oFile) (mapcar (function (lambda (pt) (write-line (strcat (itoa i) Separator (rtos (car pt) 2 *Prec*) Separator (rtos (cadr pt) 2 *Prec*) Separator (rtos (last pt) 2 *Prec*) ) oFile) (setq i (1+ i)) ) ) lstFile );c.mapcar (close oFile) (alert (strcat "File: \n\n[" sFile "]\n\nhas been created.")) ;;(startAPP (strcat "notepad.exe " sFile)) (command "shell" (strcat "start " sFile)) ) ) ) );c.cond (princ) ) (princ) I use this routine that exports coordinates, from points clicked to excel, in Csv / Txt / Xls but the exports in descending order _the last point I clicked is the first_ Can anyone reverse this? Are the points imported in the order they are clicked? --------------------------------------------------------------------------------------- Another thing, the great Lee-mac created a subroutine that would help me a lot if it were attached to the program. this link http://www.lee-mac.com/grtext.html has the subroutine, and here is the demo. (defun c:demo2 ( / *error* pnt str ) (defun *error* ( m ) (princ m) (redraw) (princ)) (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (setq str (mapcar 'rtos (trans (cadr pnt) 1 0))) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat "X=" (car str) "\nY=" (cadr str))) 3 15 -31) ) (redraw) (princ) ) This subroutine would work as a preview, so I know if I'm clicking the correct location. I thank the help of all you. Quote
rlx Posted July 18, 2018 Posted July 18, 2018 not sure if my Spanish or whatever is so good either... (mapcar (function (lambda (pt) (write-line (strcat (itoa i) Separator (rtos (car pt) 2 *Prec*) Separator (rtos (cadr pt) 2 *Prec*) Separator (rtos (last pt) 2 *Prec*)) oFile) (setq i (1+ i)))) [b](reverse lstFile)[/b] );c.mapcar Quote
JuniorNogueira Posted July 18, 2018 Author Posted July 18, 2018 not sure if my Spanish or whatever is so good either... (mapcar (function (lambda (pt) (write-line (strcat (itoa i) Separator (rtos (car pt) 2 *Prec*) Separator (rtos (cadr pt) 2 *Prec*) Separator (rtos (last pt) 2 *Prec*)) oFile) (setq i (1+ i)))) [b](reverse lstFile)[/b] );c.mapcar Thanks, that solves my problem very well. But what about the preview? is there a way to add the sub-routine from lee-mac to code? My intention is to make the program of this link with a preview >> Quote
rlx Posted July 18, 2018 Posted July 18, 2018 Thanks, that solves my problem very well.But what about the preview? is there a way to add the sub-routine from lee-mac to code? My intention is to make the program of this link with a preview >> I think that's not gonna be a problem. Will try to find some time 2nite or 2morrow have done enough computing for this day. And if sombody else want to have a go... be my guest... Quote
marko_ribar Posted July 18, 2018 Posted July 18, 2018 (edited) Here you are... Regards... coords2xls.lsp Edited July 18, 2018 by marko_ribar Quote
rlx Posted July 19, 2018 Posted July 19, 2018 Here you are... Regards... thanx for stepping in Marko Quote
JuniorNogueira Posted July 19, 2018 Author Posted July 19, 2018 Here you are... Regards... Marko ribar Very good apparently you are understanding me, but the routine does not work, when the text should be saved the message is displayed (Format file; [ / Txt / Xls]: T ; error: bad argument type: stringp nil) Another thing, as you see in the video the coordinates are automatically exposed to Excel, is it possible? Quote
rlx Posted July 19, 2018 Posted July 19, 2018 Think the problem lies with *Format* and (assoc *Format* lsts) ... case sensitive? just a dirty fix (if (not (setq Separator (cadr (assoc (strcase *Format* t) lsts)))) (setq Separator ",")) Quote
marko_ribar Posted July 20, 2018 Posted July 20, 2018 Yes rlx, that was the problem... Haven't repeated routine... Thanks... Quote
JuniorNogueira Posted July 20, 2018 Author Posted July 20, 2018 Yes rlx, that was the problem... Haven't repeated routine... Thanks... Doing some research on the internet, I discovered using ActiveX. to make this "bridge" necessary to transfer the coordinates instantly to Excel. Any suggestions on where I could find something like this? Quote
JuniorNogueira Posted July 21, 2018 Author Posted July 21, 2018 Yes rlx, that was the problem... Haven't repeated routine... Thanks... What about the instant link between AutoCAD and Excel? Is there a way to do this for whenever I click on autocad coordinate is exported instantially? 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.