Getting a list of polyline vertices using LISP
Here is one way to generate a list of polyline vertices using lisp. This function requires one argument, a polyline entity. The polyline can be the old style POLYLINE entity (2D or 3D), or it can be an LWPOLYLINE entity.
(defun getcoords (ent)
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent)
"Coordinates"
)
)
)
)
Example:
(getcoords (car (entsel)))
This function will return a list of coordinates. If the polyline is a LWPOLYLINE entity, the list will be in the form of (x y x y x y x y), and the number of vertices can be determined by dividing the length of the list by 2.
If the polyline is a POLYLINE entity (2D or 3D), then the list will be in the form of (x y z x y z x y z), and the number of vertices can be determined by dividing the length of the list by 3.
A sample of the output is shown below:
(-3.65553 2.56916 -0.83241 5.477 3.9698 3.23796 6.50188 4.54649 10.0235 2.71455 14.8257 6.78553)
All content is copyright © CAD Panacea 2008-2010 unless otherwise noted.
All content of CAD Panacea is solely my own personal thoughts and opinions and do not represent my employer or any others.
All comments posted to this blog are the sole responsibility of the person making the comment.
Google, as a third party vendor, uses cookies to serve ads on this site. Google's use of their cookies enables it to serve ads to users based on their visit to your sites and other sites on the Internet. You may opt out of the use of these cookies by visiting the Google ad and content network privacy policy.




inserting blocks at vertices
Hello,
I was wondering if you be able to help me. I would like a lisp which allows me to select multiple polylines, and then to insert a block I have made at each vertex of those polylines?
What I'm trying to do is to pick the polylines, then click and have it insert the block in place at the vertex of the polyline.
Many thanks,
Brian
Brian, take a look at the
Brian, take a look at the routine here:
http://www.cadforum.cz/cadforum_en/qaID.asp?tip=5384
Getcoord defun
Do you have a version of this defun that will work on blocks that inserted in to a drawings? If so can you email.
Thanks