Author Topic: Polyline length leader with additional text??  (Read 2537 times)

0 Members and 1 Guest are viewing this topic.

donniedrake

  • Guest
Polyline length leader with additional text??
« on: November 12, 2014, 11:53:10 AM »
Anyone have a way to select a polyline, get it's length, put that length plus additional text in a mtext with leader?

The yellow highlighted text in the example is what I'm trying to accomplish.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Polyline length leader with additional text??
« Reply #1 on: November 12, 2014, 12:06:59 PM »
Do a search. There are plenty of Label programs that can be modified.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Polyline length leader with additional text??
« Reply #2 on: November 12, 2014, 12:09:12 PM »
And here's a quicky :) to put the length.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ _getlength e l p1 p2)
  2.   (defun _getlength (ename / ep)
  3.     (if (vl-catch-all-error-p (setq ep (vl-catch-all-apply 'vlax-curve-getendparam (list ename))))
  4.       0.0
  5.       (vlax-curve-getdistatparam ename ep)
  6.     )
  7.   )
  8.   (if (and (setq e (entsel "\nSelect object with length: ")) (setq p1 (cadr e)) (setq e (car e)))
  9.     (if (and (/= 0.0 (setq l (_getlength e)))
  10.              (setq p2 (getpoint p1 "\nSpecify leader landing location: "))
  11.         )
  12.       (command "._mleader" p1 p2 l)
  13.       (princ "\nObject does not have length property...")
  14.     )
  15.   )
  16.   (princ)
  17. )
« Last Edit: November 12, 2014, 12:15:31 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ChrisCarlson

  • Guest
Re: Polyline length leader with additional text??
« Reply #3 on: November 12, 2014, 12:10:54 PM »
Wouldn't be to complicated

Code - Auto/Visual Lisp: [Select]
  1.        
  2. (setq a (car(nentsel "\nSELECT ENTITY")))
  3.         (if
  4.                 (and a
  5.                         (setq aDXF (entget a))(member (cdr (assoc 0 aDXF))'("LWPOLYLINE" "POLYLINE" "LINE" "ARC"))
  6.                         )
  7.         (progn
  8.                         (setq a_length (vla-get-length(vlax-ename->vla-object a))))
  9.         (princ "Not a valid selection")
  10.  

Then find the mid point (first point of leader), extend it and enter the text.

donniedrake

  • Guest
Re: Polyline length leader with additional text??
« Reply #4 on: November 12, 2014, 12:26:15 PM »
Side note, I'm a newbie at implementing lisp's other than existing ones. Learning slowly!