Hello!
I found a pretty good lisp to calculate the slope percentage of a segment and write it on a text object, but the problem is that is on absolute units and i would like to have one decimal place on it p.e.: i= 4,7% and not i=5%
here is the lisp routine:
;;Ranjit Singh
;;5/25/17
(defun c:slopefunc (/ pt1 pt2)
(entmakex
(list '(0 . "MTEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbMText")
(cons 10 (mapcar '+ (list 0 (/ (getvar 'textsize) 2.0)) (mapcar '/ (mapcar '+ (setq pt1 (getpoint)) (setq pt2 (getpoint))) '(2 2))))
(cons 1 (strcat "i="(rtos ((lambda (x) (* -100 (/ (cadr x) (abs (car x))))) (mapcar '- pt1 pt2)) 2 0) "%"))
'(71 . 😎
(cons 50 (if (> (car pt1) (car pt2)) (+ pi (angle pt1 pt2)) (angle pt1 pt2))))))
slope_label_2.gif
Report
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
@Anonymous wrote:
Hello!
I found a pretty good lisp to calculate the slope percentage of a segment and write it on a text object, but the problem is that is on absolute units and i would like to have one decimal place on it p.e.: i= 4,7% and not i=5%
here is the lisp routine:
;;Ranjit Singh
;;5/25/17(defun c:slopefunc (/ pt1 pt2)
(entmakex
(list '(0 . "MTEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbMText")
(cons 10 (mapcar '+ (list 0 (/ (getvar 'textsize) 2.0)) (mapcar '/ (mapcar '+ (setq pt1 (getpoint)) (setq pt2 (getpoint))) '(2 2))))
(cons 1 (strcat "i="(rtos ((lambda (x) (* -100 (/ (cadr x) (abs (car x))))) (mapcar '- pt1 pt2)) 2 0) "%"))
'(71 . 😎
(cons 50 (if (> (car pt1) (car pt2)) (+ pi (angle pt1 pt2)) (angle pt1 pt2))))))slope_label_2.gif
Report
Change the red figure.
Can't find what you're looking for? Ask the community or share your knowledge.