Jump to content

Recommended Posts

Posted

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.

Posted

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


Posted
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 >>

Posted
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...

Posted
Here you are...

 

 

Regards...

 

 

thanx for stepping in Marko :thumbsup:

Posted
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?

Posted

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 ","))

Posted

Yes rlx, that was the problem... Haven't repeated routine... Thanks...

Posted
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?

Posted
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?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...