Display full version of the post: Lisp To Label The Polyline Coordinates

thinker
12.06.2013, 17:02
Here  I ask to make change in a lisp, now i am looking for one lisp that can label the coordinates of selected polylines i attach a simple image to describe the requirments thinker2013-06-12 17:55:45

Kent Cooper
13.06.2013, 15:02
I will assume you want to label all vertices, including all ends, though your illustration appears to have labels on some but not all ends.  [If there are tiny end segments not visible, and you don't want any ends, that can be arranged.]  Getting the text content is not difficult, but getting a routine to find the location at which to put it for each vertex seems like a real challenge, so the following leaves that to the User, and steps through each vertex.  In simplest terms, and minimally tested, this seems to work:
 

(vl-load-com)(defun C:PVCL ; = PolyLine Vertex Coordinates Labeler  (/ pl par ver txt)  (setq    pl (car (entsel "\nSelect Polyline to label its vertices: "))    par -1  ); setq  (repeat (cdr (assoc 90 (entget pl))); number of vertices    (setq      ver (vlax-curve-getPointAtParam pl (setq par (1+ par)))      txt (strcat (rtos (car ver) 2 3) "\\P"  (rtos (cadr ver) 2 3))    ); setq    (command "_.leader" "_none" ver pause "" txt "")  ); repeat); defun
 
You would want to add things to set the Leader style and perhaps Layer, maybe your own prompt for the second point of the Leader, and the usual other controls [error handling, command echo suppression (in which case you would need to supply that prompt), maybe object-snap suppression (in which case you could take out the "_none"), etc.].

thinker
13.06.2013, 16:19
Thank you Mr. Kent Cooper i really need this lisp
I need to label all vertices including ends, in screenshot all vertices are labelled.I need put text location manually as in routine so text loction doesnot matter,as I check it works very good, only problem is it works in world ucs only other ucs it doesnot support,
I did not have good knowledge of lisp but as my requirement i change the code, new code is here
 
(vl-load-com)(defun C:CV ; = PolyLine Vertex Coordinates Labeler  (/ pl par ver txt)  (setq    pl (car (entsel "\nSelect Polyline to label its vertices: "))    par -1  ); setq  (repeat (cdr (assoc 90 (entget pl))); number of vertices    (setq      ver (vlax-curve-getPointAtParam pl (setq par (1+ par)))      txt (strcat (rtos (/(cadr ver) 2) 2 3) "\\P"  (rtos (car ver) 2 3))    ); setq    (command "_.leader" "_none" ver pause "" txt "")  ); repeat); defun
 
Thanks. thinker2013-06-13 16:20:31

Kent Cooper
17.06.2013, 17:10
For other-than-World Coordinate Systems, you can translate the vertex locations [which will always be returned in WCS value].  Try replacing this:
   ver (vlax-curve-getPointAtParam pl (setq par (1+ par)))
 
with this:
 
  ver (trans (vlax-curve-getPointAtParam pl (setq par (1+ par))) 0 1)
 
The 0 means translate from the WCS, and the 1 means translate to the current Coordinate System [see the AutoLISP Reference about the (trans) function].Kent Cooper2013-06-17 17:11:41

Vladimir Michl
19.06.2013, 13:59
You can also use dynamic blocks and the VerticesBlk tool - see the video:
http://www.youtube.com/watch?v=fFSrWutRNsk
and the tip:
http://www.cadforum.cz/cadforum_en/automatic-vertex-labels-with-autonumbering-and-coordinates-tip8361
 

thinker
26.06.2013, 05:58
sorry for late reply i am too busy in my office
@Kent Cooper thank you it works very good, i will study your recomanded function
@Vladimir Michl as per my illustration i need coordinates with leader, i will see video later
Thanks to all.thinker2013-06-26 06:28:57

sahaj
26.06.2013, 14:44
I have used this lisp many times for labeling the x - y co-ordinates; Limitation; ----------; Will use current leader style and current units setting(defun c:lb (/  p x y ptcoord textloc)  (while    (setq p (getpoint "\nPick Point: "))    (setq textloc (getpoint "\nPick Label Location: "))    (setq x (rtos (car p)))    (setq y (rtos (cadr p)))    (setq ptcoord (strcat x ", " y))    (command "_LEADER" p textloc "" ptcoord "")  ))

thinker
04.07.2013, 11:12
@sahaj, this lisp does not pick next vertex automatically.

John Connor
04.07.2013, 12:51
The Stones: "You can't always get what you want."