Layer Name LISP at End of Line or Polyline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a lisp file that labels the layer of a line at the midpoint but I need it to label the line at the end point. What do I need to change in the lisp file to adjust the location the text is placed?
This is the lisp file:
(defun c:lln3 (/ *error* mk_txt
DOC ENT I IPT LANG OFAC P SPC SS TOBJ TSZE UFLAG)
(vl-load-com)
(setq oFac 0.7) ;; Offset Factor
(setq tSze nil) ;; Text Size ~ nil for TEXTSIZE Variable
(defun *error* (msg)
(and uFlag (vla-EndUndoMark doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ))
(defun mk_txt (p v) (vla-addText spc v (vlax-3D-point p) tSze))
(setq doc (vla-get-ActiveDocument
(vlax-get-Acad-Object))
spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc)))
(or tSze (setq tSze (getvar "TEXTSIZE")))
(if (setq i -1 ss (ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
(progn
(setq uFlag (not (vla-StartUndoMark doc)))
(while (setq ent (ssname ss (setq i (1+ i))))
(setq iPt (vlax-curve-getPointatDist ent
(/ (- (vlax-curve-getDistatParam ent
(vlax-curve-getEndParam ent))
(vlax-curve-getDistatParam ent
(vlax-curve-getStartParam ent))) 2.)))
(setq lAng (angle '(0 0 0) (vlax-curve-getFirstDeriv ent
(vlax-curve-getParamatPoint ent iPt))))
(if (equal lAng (/ pi 2.) 0.001) (setq lAng (/ pi 2.)))
(if (equal lAng (/ (* 3 pi) 2.) 0.001) (setq lAng (/ (* 3 pi) 2.)))
(cond ( (and (> lAng (/ pi 2)) (<= lAng pi)) (setq lAng (- lAng pi)))
( (and (> lAng pi) (<= lAng (/ (* 3 pi) 2))) (setq lAng (+ lAng pi))))
(setq tObj (mk_txt (setq p (polar iPt (+ lAng (/ pi 2.)) (* oFac tSze)))
(vla-get-Layer (vlax-ename->vla-object ent))))
(vla-put-Alignment tObj acAlignmentMiddleCenter)
(vla-put-TextAlignmentPoint tObj (vlax-3D-point p))
(vla-put-Rotation tObj lAng))
(setq uFlag (vla-EndUndoMark doc))))
(princ))