15-13A. Autocad Export Coordinates Points To Csv
How to Export Coordinates of Points Using LISP to AutoCAD
Since this spider web tutorial is intended for beginners, hither I volition clitoris how to export Coordinates for specific points inward the drawing.
Take for representative that the drawings convey points that are laid to specific coordinates (this is quite used inward geodesy, but generally MAP CAD programs in addition to merely about already convey built-in LISP Export programs).
In the motion painting below, notice that I convey created several points on the desktop. Note that amongst the cursor I convey an extra cloud amongst the coordinate seat if I click on the seat where the cursor is currently located. (this cloud tin hold upwards switched on/off at the DYN clitoris (dynamic input)
Take for representative that the drawings convey points that are laid to specific coordinates (this is quite used inward geodesy, but generally MAP CAD programs in addition to merely about already convey built-in LISP Export programs).
In the motion painting below, notice that I convey created several points on the desktop. Note that amongst the cursor I convey an extra cloud amongst the coordinate seat if I click on the seat where the cursor is currently located. (this cloud tin hold upwards switched on/off at the DYN clitoris (dynamic input)
How to usage LISP?
To usage this choice (export coordinates to CSV file), a file that has the extension '* .lsp' is used. This so-called scripted code needs to hold upwards copied to the "some" folder. Usually this is the AutoCAD folder that contains other files amongst the LSP extension. In AutoCAD 2007 it is a Express folder (if y'all installed it when installing AutoCAD)
For this representative I works life i file (named c2exc2.lsp) that exports coordinates to Excel format. Source code y'all tin come across below.
CODE:
;;; Export coordinates of dwg dots inward excel format (three decimal places).
;;; Load Lisp (Tools => AutoLisp => Load Application => c2exc2
;;; NOTE: lisp is started past times typing c2exc2 commands inward the ascendancy line
(defun C:c2exc2 (/ coords coor_list elist en fd fname i ss)
(setq ss
(ssget "_:S" '((0 . "*POLYL*,LINE,CIRCLE,ARC,ELLIPSE,SPLINE,POINT"))) i -1)
(repeat (sslength ss)
(setq i (1+ i)
en (ssname ss i)
elist (entget en)
coords (vl-remove-if (function not)
(mapcar (function (lambda (x)(if (eq 10 (car x))(trans (cdr x) 0 1))))
elist)
)
coor_list (cons coords coor_list)))
(setq coor_list (reverse coor_list))
(setq fname (getfiled "Type file name" "" "xls" 1))
(setq fd (open fname "w"))
(foreach coors coor_list
(foreach i coors
(princ (strcat (rtos(car i)) "\t"
(rtos (cadr i))"\t"
(rtos (caddr i)) "\n")
fd)
)
)
(close fd)
(princ)
)
After setting the points on the drawing, it is necessary to charge the LISP file that draws the export coordinate of the selected points to the drawing into the CSV file that y'all tin opened upwards inward Excel.
So to charge LISP, click on TOOLS => AutoLISP => Load Application
For this representative I works life i file (named c2exc2.lsp) that exports coordinates to Excel format. Source code y'all tin come across below.
CODE:
;;; Export coordinates of dwg dots inward excel format (three decimal places).
;;; Load Lisp (Tools => AutoLisp => Load Application => c2exc2
;;; NOTE: lisp is started past times typing c2exc2 commands inward the ascendancy line
(defun C:c2exc2 (/ coords coor_list elist en fd fname i ss)
(setq ss
(ssget "_:S" '((0 . "*POLYL*,LINE,CIRCLE,ARC,ELLIPSE,SPLINE,POINT"))) i -1)
(repeat (sslength ss)
(setq i (1+ i)
en (ssname ss i)
elist (entget en)
coords (vl-remove-if (function not)
(mapcar (function (lambda (x)(if (eq 10 (car x))(trans (cdr x) 0 1))))
elist)
)
coor_list (cons coords coor_list)))
(setq coor_list (reverse coor_list))
(setq fname (getfiled "Type file name" "" "xls" 1))
(setq fd (open fname "w"))
(foreach coors coor_list
(foreach i coors
(princ (strcat (rtos(car i)) "\t"
(rtos (cadr i))"\t"
(rtos (caddr i)) "\n")
fd)
)
)
(close fd)
(princ)
)
After setting the points on the drawing, it is necessary to charge the LISP file that draws the export coordinate of the selected points to the drawing into the CSV file that y'all tin opened upwards inward Excel.
So to charge LISP, click on TOOLS => AutoLISP => Load Application
How to charge LISP file?
At the adjacent dialog window y'all honor the folder inward which y'all copied the file 'c2wxc2.lsp'. In this case, it is a folder Express in addition to contains the file inward question. Select it (tick) in addition to and thence click the LOAD button. If AutoCAD has successfully loaded the relevant file, this information volition hold upwards displayed inward the champaign (shown inward Figure four - 'c2exc2.lsp' successfully loaded)
After uploading the LISP file, y'all are ready to export specific betoken coordinates to a CSV file that you tin opened upwards inward Excel. Note the drawing (figure below) for this representative of 5 dots (they produce non convey to await similar this, I've shaped them into this layout for easier explanation.) From drawn 5 points I desire to honor 3 betoken coordinates (ie export them)
In Coomand Line, instruct inward the ascendancy "c2exc2" amongst no quotation marks. Make certain that this ascendancy does non ever convey to hold upwards the same file name. That's why y'all bespeak to proceed inward hear the advert of the ascendancy inward the source code. See the get-go row of commands inward the source code.
(defun C:c2exc2 (/ coords coor_list elist en fd fname i ss)
So hither is the ascendancy that LISP launches. (all depends on the developer who programmed the LISP code).
After pressing the ENTER key, the mouse pointer has been transformed into 'square' in addition to inward Command Line AutoCAD requires us to lead (highlight) all the points for which nosotros desire to export the coordinates. As y'all lead AutoCAD, come across link AutoCAD Selection With Mouse.
Select multiple points inward AutoCAD
So, I volition lead the 3 points for which I volition Export the Coordinates to Excel past times selecting them inward the " click mouse-hold the mouse in addition to drag it-drop" organisation to include them inward a selective rectangle. Of course of report y'all tin lead (highlight) the betoken past times point.
After the choice has been completed, it is necessary to specify the Folder or New Folder inward which nosotros volition capture the CSV file in addition to advert it amongst merely about meaningful advert that nosotros volition afterwards hold upwards aware of.
Now let's opened upwards the captured file in addition to come across inward the opened upwards file a List of Coordinates from AutoCAD where nosotros are A=X i B=Y axis
View Coordinates inward AutoCAD
View Coordinates inward Excel