Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 1 of 11 (1,681 Views)

Extract Point Data - CALLING ALL LISP GURUS!

1681 Views, 10 Replies
09-18-2000 05:06 PM
I would like a lisp routine that can extract and export the x, y, z coordinates of all the points in a drawing into a text file so I can use the same in excel. Please help. Thanks in advance, PM
*Dotson, Terry W.
Message 2 of 11 (1,683 Views)

Re: Extract Point Data - CALLING ALL LISP GURUS!

09-18-2000 06:35 PM in reply to: pmahajan
pmahajan wrote:

> I would like a lisp routine that can extract and export the x, y, z
> coordinates of all the points in a drawing into a text file so I can
> use the same in excel.

If you were to consider third party software, ToolPac 5.0 from
http://www.dotsoft.com does this.

Terry
*Tanzillo, Tony
Message 3 of 11 (1,683 Views)

Re: Extract Point Data - CALLING ALL LISP GURUS!

09-18-2000 08:27 PM in reply to: pmahajan
pmahajan wrote:
>
> I would like a lisp routine that can extract and export the x, y, z coordinates of all
> the points in a drawing into a text file so I can use the same in excel. Please help.
> Thanks in advance, PM

The LISP code below adds the WPOINT command to AutoCAD that
will write the X,Y and Z of selected POINT entities to a .CSV
file that you can open directly in Excel.

;; --------------------------------------------------------------------
;; WPOINT.LSP Copyright 1990-2000 Tony Tanzillo

(defun C:WPOINT ( / ss fd file)
(cond
( (not (setq ss (ssget '((0 . "POINT"))))))
( (not (setq file (getfiled "Export Points" "" "csv" 1))))
( (not (setq fd (open file "w")))
(alert "Unable to open file for output"))
(t (repeat (setq i (sslength ss))
(write-point
(ssname ss (setq i (1- i)))
fd
6
)
)
(close fd)
)
)
(princ)
)

(defun write-point (e fd prec / p)
(setq p (cdr (assoc 10 (entget e))))
(write-line
(strcat (rtos (car p) 2 prec) ","
(rtos (cadr p) 2 prec) ","
(rtos (caddr p) 2 prec)
)
fd
)
)

;; --------------------------------------------------------------------

--

Checkout the AcadX(tm) ActiveX Extension Library at:

http://www.caddzone.com/acadx/acadx.htm

/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://www.caddzone.com */
/*********************************************************/
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 4 of 11 (1,683 Views)

Re:

09-22-2000 11:50 AM in reply to: pmahajan
Thanks Tony,
You are the CAD GURU.......solved the problem in a second. Appreciate all the responses from the other gurus too!!

Regards,
PM
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 5 of 11 (1,683 Views)

Re:

09-22-2000 12:06 PM in reply to: pmahajan
Tony a quick question:
Would it be very difficult to modify wpoint.lsp to work for other cad entities such as polylines and blocks also??

Thnks.
PM
*Tanzillo, Tony
Message 6 of 11 (1,683 Views)

Re:

09-22-2000 12:39 PM in reply to: pmahajan
No, but in the case of polylines, what exactly
is it you want to export? If you want to represent
the ordered vertices of one or more polylines in
a plain ASCII file, then doesn't there need to be
some additional information to delimit the start
and end of each polyline, or are the vertex points
the only thing you need to export?

This version will also do blocks, but it does not
filter by block name, which you could also do if
you need:

(defun C:WPOINT ( / ss fd file)
(cond
( (not (setq ss (ssget '((0 . "POINT,INSERT"))))))
( (not (setq file (getfiled "Export Points" "" "csv" 1))))
( (not (setq fd (open file "w")))
(alert "Unable to open file for output"))
(t (repeat (setq i (sslength ss))
(write-point
(ssname ss (setq i (1- i)))
fd
6
)
)
(close fd)
)
)
(princ)
)

pmahajan wrote:
>
> Tony a quick question:
> Would it be very difficult to modify wpoint.lsp to work for other cad entities such as
> polylines and blocks also??
>
> Thnks.
> PM

--

Checkout the AcadX(tm) ActiveX Extension Library at:

http://www.caddzone.com/acadx/acadx.htm

/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://www.caddzone.com */
/*********************************************************/
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 7 of 11 (1,683 Views)

Re:

09-22-2000 01:05 PM in reply to: pmahajan
Thank you Tony, but the one for blocks does not seem to work correctly. Once it creates a CSV file, there is nothing in it for some reason. If Im doing something wrong, please let me know because this lisp will be a saving grace for me. I have used your other lisp routine for the polylines so Im all set, the only problem is the blocks.
Thanks again, PM.
*Tanzillo, Tony
Message 8 of 11 (1,683 Views)

Re:

09-22-2000 01:23 PM in reply to: pmahajan
The function I posted is a replacement for the
function of the same name from the WPOINT.LSP
file. You have to replace the existing C:WPOINT
function in WPOINT.LSP with the version I posted
in the last message. Then, load WPOINT.LSP and
it should work.

You must select the objects you are going to
export. If you want to export all objects, you
just type ALL at the Select Objects: prompt.

pmahajan wrote:
>
> Thank you Tony, but the one for blocks does not seem to work correctly. Once it creates
> a CSV file, there is nothing in it for some reason. If Im doing something wrong, please
> let me know because this lisp will be a saving grace for me. I have used your other lisp
> routine for the polylines so Im all set, the only problem is the blocks.
> Thanks again, PM.

--

Checkout the AcadX(tm) ActiveX Extension Library at:

http://www.caddzone.com/acadx/acadx.htm

/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://www.caddzone.com */
/*********************************************************/
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 9 of 11 (1,683 Views)

Re:

09-22-2000 04:39 PM in reply to: pmahajan
Alright Tony:
I have followed your instructions
--used the following..... (defun C:WPOINT ( / ss fd file) (cond ( (not (setq ss (ssget '((0 . "POINT,INSERT")))))) ( (not (setq file (getfiled "Export Points" "" "csv" 1)))) ( (not (setq fd (open file "w"))) (alert "Unable to open file for output")) (t (repeat (setq i (sslength ss)) (write-point (ssname ss (setq i (1- i))) fd 6 ) ) (close fd) ) ) (princ) ) ....in place of wpoint.lsp that you sent me initially and here is what shows up after selecting all the objects in the drawing in the Autocad text box..... Select objects:
error: null function
(WRITE-POINT (SSNAME SS (SETQ I (1- I))) FD 6)
(REPEAT (SETQ I (SSLENGTH SS)) (WRITE-POINT (SSNAME SS (SETQ I (1- I))) FD 6))
(COND ((NOT (SETQ SS (SSGET (QUOTE ((0 . "POINT,INSERT"))))))) ((NOT (SETQ FILE
(GETFILED "Export Points" "" "csv" 1)))) ((NOT (SETQ FD (OPEN FILE "w")))
(ALERT "Unable to open file for output")) (T (REPEAT (SETQ I (SSLENGTH SS))
(WRITE-POINT (SSNAME SS (SETQ I (1- I))) FD 6)) (CLOSE FD)))
(C:WPOINT)
*Cancel* ......how should I fix this problem Tony??
Regs
PM
Contributor
pmahajan
Posts: 22
Registered: ‎09-28-2000
Message 10 of 11 (1,683 Views)

Re:

09-22-2000 04:58 PM in reply to: pmahajan
Alright Alright Alright Tony........IT WORKS LIKE A BREEZE!!!Thanks a million.
Regs,
PM

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community