;;----------------------------------------------------------------------;;
;; http://www.theswamp.org/index.php?topic=42402.0 ;;
;;----------------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;
;;----------------------------------------------------------------------;;
;; Version 0.0 - August 03, 2012, 11:59:29 am ;;
;; ;;
;; First release - previously 'Line with aligned text'. ;;
;;----------------------------------------------------------------------;;
;; Modified by Luís Augusto ;;
;; Changes for personal use ;;
;; Entering getInt ;;
;; Setting the value of the text in 3.0 ;;
;; Setting Justify Botton Center ;;
;; Setting offset of text in relation to the line 0.0 ;;
;; Entering Looping function ;;
;;----------------------------------------------------------------------;;
(defun c:dmid
( / an di p1 p2 tp
) ;; Define function, localise variables (if ;; if the following test expression returns a non-nil value (and ;; all of the following expressions must return a non-nil value ;; Collect the first point from the user, assign to p1
;; Collect the second point from the user, rubber-band to p1, assign to p2
) ;; end and
(progn ;; Evaluate the following expressions as the 'then' expression for the if function ;; Calculate the distance between the points
;; Calculate the angle between the points
;; Calculate the point for the Text
(polar p1 an
(/ di
2.0)) ;; Line midpoint (+ an (/ pi 2.0)) ;; Perpendicular to Line
0 ;Offset 0
;(getvar 'textsize) ;; Offset by text height
)
)
;; Text above
((< an
(* pi
1.5) (setq an
(+ an pi
)))) ((> an
(* pi
1.5) (setq an
(+ an pi
)))) )
;; Create the line between the points
'(0 . "LINE") ;; Entity type
(cons 10 p1
) ;; Start point (cons 11 p2
) ;; End point ) ;; end list
) ;; end entmake
;; Create the text to display the distance
(setq cont
(getint "\nEnter the value :")) ;;Get value text content '(0 . "TEXT") ;; Entity type
(cons 10 tp
) ;; Insertion Point (cons 11 tp
) ;; Alignment POint ;(cons 1 (rtos di)) ;; Content
;(cons 40 (getvar 'textsize)) ;; Height
'(72 . 1) ;; Center
'(73 . 1) ;; 0 Center / 1 Botton Center / 2 Middle Center ....
) ;; end list
) ;; end entmake
) ;; end progn
) ;; end if
(princ) ;; Suppress the return of the last evaluated expression (Loop)
) ;; end defun
(defun Loop
(/ ang dist tpp
) (if ;; if the following test expression returns a non-nil value (and ;; all of the following expressions must return a non-nil value ;; Define pnext
;; Collect the second point from the user, rubber-band to pnext, assign to p2
) ;; end and
(progn ;; Evaluate the following expressions as the 'then' expression for the if function ;; Calculate the distance between the points
;; Calculate the angle between the points
;; Calculate the point for the Text
(polar pnext ang
(/ dist
2.0)) ;; Line midpoint (+ ang (/ pi 2.0)) ;; Perpendicular to Line
0 ;Offset 0
;(getvar 'textsize) ;; Offset by text height
)
)
;; Text above
((< ang
(* pi
1.5) (setq ang
(+ ang pi
)))) ((> ang
(* pi
1.5) (setq ang
(+ ang pi
)))) )
;; Create the line between the points
'(0 . "LINE") ;; Entity type
(cons 10 pnext
) ;; Start point (cons 11 p2
) ;; End point ) ;; end list
) ;; end entmake
;; Create the text to display the distance
(setq cont
(getint "\nEnter the value :")) ;;Get value text content '(0 . "TEXT") ;; Entity type
(cons 10 tpp
) ;; Insertion Point (cons 11 tpp
) ;; Alignment POint ;(cons 1 (rtos dist)) ;; Content
;(cons 40 (getvar 'textsize)) ;; Height
'(72 . 1) ;; Center
'(73 . 1) ;; 0 Center / 1 Botton Center / 2 Middle Center ....
) ;; end list
) ;; end entmake
) ;; end progn
) ;; end if
(princ) ;; Suppress the return of the last evaluated expression (Loop1)
) ;; end defun
(princ) ;; Suppress return of expression evaluated on load