Jump to content

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


Recommended Posts

Posted

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)
         
        
         
         

  • 2 months later...
Posted

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

  • 2 weeks later...
Posted
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.

  • 5 months later...
Posted
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

Posted

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

Posted

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

  • 6 months later...
Posted
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

Posted

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?

Posted

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

Posted (edited)

1. The figure shows a polyline or lines ?

2. Marked text will always be in the middle of segment?

Edited by VVA
  • 4 months later...
Posted (edited)

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
Posted

Where are the Coor, CoorN and CoorNP commands?

Posted

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

  • 3 months later...
Posted

Thank you for the lisps - I work in Acad 2000 and they did the job. Great!

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