Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
vonniea
Posts: 9
Registered: ‎11-19-2002
Message 1 of 4 (2,622 Views)

Using LISP to get the x,y coordinates of a pline

2622 Views, 3 Replies
02-01-2012 02:58 PM

 Is there anyway to use LISP to list the x,y coordinates of a pline?

                          Vonnie A.

Mentor
devitg
Posts: 1,705
Registered: ‎03-14-2004
Message 2 of 4 (2,615 Views)

Re: Using LISP to get the x,y coordinates of a pline

02-01-2012 06:01 PM in reply to: vonniea
yes , get all the code 10 for a pline
*Expert Elite*
Kent1Cooper
Posts: 5,796
Registered: ‎09-13-2004
Message 3 of 4 (2,608 Views)

Re: Using LISP to get the x,y coordinates of a pline

02-01-2012 08:49 PM in reply to: vonniea

vonniea wrote:

 Is there anyway to use LISP to list the x,y coordinates of a pline?

....


What format do you need them in?  For a Lightweight Polyline, this will give you a simple list of the X & Y coordinates of the vertices, undivided into individual points [supply appropriate information in place of the green parts]:

 

(vlax-get (vlax-ename->vla-object PlineEntityName) 'Coordinates)

 

Or [again for a Lightweight Polyline] this will give you a list of two-coordinate lists [the same as above, but divided into a separate pair for each vertex], removing the 10's from the vertex entity data entries:

 

(mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) PlineEntityData))

 

Might you sometimes be working with "heavy" Polylines [2D or 3D]?  Some adjustment would need to be made to get rid of the Z coordinates that the above functions would include for those.

 

Other adjustments would need to be made if you need them as comma-separated pairs, or written out to a file, or....

Kent Cooper
Valued Mentor
gjrcmb
Posts: 326
Registered: ‎06-21-2011
Message 4 of 4 (2,602 Views)

Re: Using LISP to get the x,y coordinates of a pline

02-01-2012 09:53 PM in reply to: vonniea

Test out the attached for LWPolylines, by loading file with APPLOAD and then typing PLVERTEX.  Application will list all x,y coordinates for vertices of polyline.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!