Had some time to spare today and it seemed like a nice challenge, so here it is (no error cheching or anything, not even sure if this is what you want, feel free to modify and improve).
(defun R->D (Rads)
(* 180.0 (/ Rads pi))
)
;
(defun CreateFence ( / PointPicked P1)
(setq FencePointsList nil)
(setq PointPicked (getpoint "\nSelect First Fence point.."))
(setq P1 PointPicked)
(setq FencePointsList (append FencePointsList (list PointPicked)))
(while (/= PointPicked nil)
(setq PointPicked (getpoint PointPicked"\nSelect Following Fence point.."))
(if (/= PointPicked nil)(progn
(setq FencePointsList (append FencePointsList (list PointPicked)))
(grdraw P1 PointPicked 6 3)
(setq P1 PointPicked)
)
)
)
(princ)
);end CreateFence
;
(defun CheckInterSect ()
(setq OldOsmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(if (= (getvar "DIMSCALE") 0)(setvar "DIMSCALE" 1))
(setq TxtHeight (* (getvar "DIMSCALE") 3.5))
(setq Cnt 0)
(setq Ent (ssget "_F" FencePointsList '((0 . "LINE,POLYLINE,LWPOLYLINE"))))
(while (/= (ssname Ent Cnt) nil)
(progn
(setq CntA 0)
(setq StartPoly (list (cadr (assoc 10 (entget (ssname Ent Cnt))))(caddr (assoc 10 (entget (ssname Ent Cnt))))))
(setq EndPoly (list (cadr (assoc 11 (entget (ssname Ent Cnt))))(caddr (assoc 11 (entget (ssname Ent Cnt))))))
(setq StartPolyZ (cadddr (assoc 10 (entget (ssname Ent Cnt)))))
(setq EndPolyZ (cadddr (assoc 11 (entget (ssname Ent Cnt)))))
(while (/= (nth cntA FencePointslist) nil)
(progn
(setq StartFence (list (car (nth CntA FencePointslist))(cadr (nth CntA FencePointslist))))
(setq CntA (+ CntA 1))
(if (/= (nth CntA FencePointslist) nil)
(progn
(setq EndFence (list (car (nth CntA FencePointslist))(cadr (nth CntA FencePointslist))))
(if (/= (inters StartPoly EndPoly StartFence EndFence) nil)
(progn
(setq TxtAngle (R->D (angle StartPoly EndPoly)))
(setq TxtPoint (inters StartPoly EndPoly StartFence EndFence))
(command ".text" "M" TxtPoint TxtHeight TxtAngle (rtos StartPolyZ 2 2))
);end progn
);end if
);end progn
);end if
);end progn
);end while
(setq Cnt (+ Cnt 1))
);end progn
);end while
(setvar "OSMODE" OldOsmode)
);end defun CheckInterSect
;
(defun c:PolyLineHeight ()
(CreateFence)
(CheckInterSect)
(command "_redraw")
(princ)
)
Kind regards,
Jimmy