Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

add decimal place in lisp routine

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
527 Views, 3 Replies

add decimal place in lisp routine

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

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

ok 😅 where the 😎 appears it is supposed to be the number "8" followed by the ")", hope you understand 😅

Message 3 of 4
ВeekeeCZ
in reply to: Anonymous


@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.

Message 4 of 4
Anonymous
in reply to: ВeekeeCZ

thankyou very much 🙂 it is solved

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta