CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.096.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator and the updated Barcode generator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedLisp To Label The Polyline Coordinates

 Post Reply Post Reply
Author
thinker View Drop Down
Groupie
Groupie


Joined: 08.Jun.2013
Location: United Arab Emirates
Using: AutoCAD2021
Status: Offline
Points: 35
Direct Link To This Post Topic: Lisp To Label The Polyline Coordinates
    Posted: 12.Jun.2013 at 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

Edited by thinker - 12.Jun.2013 at 17:55
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 686
Direct Link To This Post Posted: 13.Jun.2013 at 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.].
Back to Top
thinker View Drop Down
Groupie
Groupie


Joined: 08.Jun.2013
Location: United Arab Emirates
Using: AutoCAD2021
Status: Offline
Points: 35
Direct Link To This Post Posted: 13.Jun.2013 at 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.Clap
 


Edited by thinker - 13.Jun.2013 at 16:20
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 686
Direct Link To This Post Posted: 17.Jun.2013 at 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].


Edited by Kent Cooper - 17.Jun.2013 at 17:11
Back to Top
Vladimir Michl View Drop Down
Moderator Group
Moderator Group

Arkance Systems CZ

Joined: 26.Jul.2007
Location: Czech Republic
Using: Autodesk software
Status: Offline
Points: 2120
Direct Link To This Post Posted: 19.Jun.2013 at 13:59
Vladimir Michl (moderator)
ARKANCE - https://arkance.world - Autodesk Platinum Partner
Back to Top
thinker View Drop Down
Groupie
Groupie


Joined: 08.Jun.2013
Location: United Arab Emirates
Using: AutoCAD2021
Status: Offline
Points: 35
Direct Link To This Post Posted: 26.Jun.2013 at 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.


Edited by thinker - 26.Jun.2013 at 06:28
Back to Top
sahaj View Drop Down
Newbie
Newbie


Joined: 26.Jun.2013
Location: India
Using: Autocad 2013, Revit 2013
Status: Offline
Points: 3
Direct Link To This Post Posted: 26.Jun.2013 at 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 "")
  )
)


Cad Services
Back to Top
thinker View Drop Down
Groupie
Groupie


Joined: 08.Jun.2013
Location: United Arab Emirates
Using: AutoCAD2021
Status: Offline
Points: 35
Direct Link To This Post Posted: 04.Jul.2013 at 11:12
@sahaj, this lisp does not pick next vertex automatically.
Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
Direct Link To This Post Posted: 04.Jul.2013 at 12:51
The Stones: "You can't always get what you want." 
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,156 seconds.