Jump to content

Lisp: coordinates of points to excel sheet (+point number)


janwillem89

Recommended Posts

Hey dude,

 

Give this a shot:

 

(defun c:pExt (/ *error* acc doc spc ent tmp file pt)
 (vl-load-com)

 (setq acc 2)  ;; Accuracy

 (defun *error* (msg)
   (if doc (vla-EndUndoMark doc))
   (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (vlax-get-acad-object))
       
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))
 
 (while
   (progn
     (setq ent (car (entsel "\nSelect Polyline: ")))
     (cond (  (eq 'ENAME (type ent))
              (if (not
                    (wcmatch
                      (strcase
                        (cdr (assoc 0 (entget ent)))) "*POLYLINE"))
                (princ "\n** Invalid Object Selected **")))
           (t (princ "\n** Nothing Selected **")))))  

 (or *def* (setq *def* 2.0))
 (initget 6)
 (and (setq tmp
        (getdist
          (strcat "\nSpecify Interval for Measurement <"
                  (vl-princ-to-string *def*) "> : ")))
      (setq *def* tmp))

 (if (setq file (getfiled "Select Output File" (cond (*out) ("")) "txt;csv" 9))
   (progn
     (vla-StartUndoMark doc)      

     (setq *out file file (open file "a") i -1)
     (write-line (delim '("X" "Y" "Z") 9) file)
     
     (while (setq pt (vlax-curve-getPointatDist ent (* (setq i (1+ i)) *def*)))
       (vla-AddPoint spc (vlax-3D-point pt))
       (write-line (delim (mapcar
                            (function
                              (lambda (x)
                                (rtos x 2 acc))) pt) 9) file))
     (close file)
     (vla-EndUndoMark doc))
   
   (princ "\n*Cancel*"))
 (princ))

(defun delim (lst chc / x y)
 (setq x (car lst))
 (foreach y (cdr lst)
   (setq x (strcat x (chr chc) y)))
 x)
         
        
         
         

Link to comment
Share on other sites

  • 2 months later...

hi

i have many blocks in autocad file, i want to import xyz of any block to an Excel file. i dont know to use CoorN som one tell me step by step please

Link to comment
Share on other sites

  • 2 weeks later...
stevesfr

you use what version MS OFFICE? (I did not test with Office 2007)

In any case I have a little changed programs. Now it is possible to keep in a text file csv or txt a format.

 

If option Excell does not work, try option Text file (csv a format) and to answer "YES" inquiry "Open text file? [Yes/No] :"

 

Commands:

COOR - export of coordinates

COORN-export of coordinates with numbering. Numbers of points are drawn by the text on the current layer, the current style, current height (TEXTSIZE)

COORT-export of coordinates with numbering where number considers the text nearest to a point

CoorNP-Coordinates + Numbers + Points. Draw points with current value of PDMODE and PDSIZE

**ADD 2009-12-16 **

EcoorE.lsp - lisp file without russian text

 

PS especially it was not tested, mistakes are possible

PPS and one was found

EcoorE.lsp works perfect on my machine ,it is really a good LISP file.

Link to comment
Share on other sites

  • 5 months later...
stevesfr

you use what version MS OFFICE? (I did not test with Office 2007)

In any case I have a little changed programs. Now it is possible to keep in a text file csv or txt a format.

 

If option Excell does not work, try option Text file (csv a format) and to answer "YES" inquiry "Open text file? [Yes/No] :"

 

Commands:

COOR - export of coordinates

COORN-export of coordinates with numbering. Numbers of points are drawn by the text on the current layer, the current style, current height (TEXTSIZE)

COORT-export of coordinates with numbering where number considers the text nearest to a point

CoorNP-Coordinates + Numbers + Points. Draw points with current value of PDMODE and PDSIZE

**ADD 2009-12-16 **

EcoorE.lsp - lisp file without russian text

 

PS especially it was not tested, mistakes are possible

PPS and one was found

Vva

this is great, but could you amend this as to put a leader to the point and then the number and if possible the number with S in front of it eg S1, S2 etc

 

Many thanks

Rob

Using Autocad 2010

Link to comment
Share on other sites

Lee Mac

this is great, but could you amend this as to put a leader to the point and then the number and if possible the number with S in front of it eg S1, S2 etc

 

Many thanks

Rob

Using Autocad 2010

Link to comment
Share on other sites

Dear VVa

 

want one help from you want extract xyz and rotation angel of blocks on polyline is their any lisp? and one more thing i tried with coorn in that i can extract xyz but cant extract rotation angel plz help me

Link to comment
Share on other sites

  • 6 months later...
stevesfr

you use what version MS OFFICE? (I did not test with Office 2007)

In any case I have a little changed programs. Now it is possible to keep in a text file csv or txt a format.

 

If option Excell does not work, try option Text file (csv a format) and to answer "YES" inquiry "Open text file? [Yes/No] :"

 

Commands:

COOR - export of coordinates

COORN-export of coordinates with numbering. Numbers of points are drawn by the text on the current layer, the current style, current height (TEXTSIZE)

COORT-export of coordinates with numbering where number considers the text nearest to a point

CoorNP-Coordinates + Numbers + Points. Draw points with current value of PDMODE and PDSIZE

**ADD 2009-12-16 **

EcoorE.lsp - lisp file without russian text

 

PS especially it was not tested, mistakes are possible

PPS and one was found

 

 

How If I want to Extport Dimension of an autocad object to excels? (sorry, my english not good)....

Thanks

Link to comment
Share on other sites

Irawanaja, my English is not good too.

And accordingly I did not understand.

What do you mean when you say Dimension?

AutoCAD Dimension object 46f18fb24fb1.jpg or a length of object, such as line, or polyline?

Link to comment
Share on other sites

Tanks to your time Geobuilder, i mean length of object and the text of the object and i want to sort all to excels, like this image

 

 

ScreenHunter_02 Jan. 02 10.13.gif

Link to comment
Share on other sites

  • 4 months later...

Can ECoorE.lsp be made to do Midpoints as well as Endpoints???

And also to include Z co-ordinates along with the XY co-ords???

Edited by kcrawford
Link to comment
Share on other sites

the figure shows as polylines and / or lines (both) and the marker texts does not always in the middle of segment, i want to use the marker texts as sign where the lines / p. line if the dimension exsported to ms excels. tks

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...

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