我的老朋友。。。
- (defun c:Test (/ *error* pl i sn)
- (vl-load-com)
- (defun *error* (msg)
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")))
- (princ)
- )
- (cond ((not acdoc) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))))
- (princ "\n select a Polyline :")
- (if (setq pl (ssget '((0 . "*POLYLINE"))))
- (progn (vla-StartUndoMark acdoc)
- (repeat (setq i (sslength pl)) (setq sn (ssname pl (setq i (1- i)))) (WriteLengthsForSegments sn))
- (vla-EndUndoMark acdoc)
- )
- (princ)
- )
- (princ "\n Written By Tharwat Al Shoufi")
- (princ)
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun WriteLengthsForSegments (sn / j a b sty txt)
- (progn (setq j 0)
- (repeat (fix (vlax-curve-getendparam sn))
- (setq a (vlax-curve-getpointatparam sn j))
- (setq b (vlax-curve-getpointatparam sn (setq j (1+ j))))
- (setq
- txt (entmakex
- (list '(0 . "MTEXT")
- '(100 . "AcDbEntity")
- '(100 . "AcDbMText")
- (assoc 8 (entget sn))
- (cons 10 (mapcar '(lambda (x y) (/ (+ y x) 2.)) a b))
- (cons 7 (getvar 'textstyle))
- (cons 40
- (if (eq (cdr (assoc 40 (setq sty (entget (tblobjname "style" (getvar 'textstyle)))))) 0.)
- (cdr (assoc 42 sty))
- (cdr (assoc 40 sty))
- )
- )
- (cons 1 (rtos (distance a b) 2))
- (cons 50 (angle a b))
- '(71 . 5)
- )
- )
- )
- (vla-put-BackgroundFill (vlax-ename->vla-object txt) -1)
- )
- )
- )
|