- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
We need draw slope symbol for each profile drawing, I try to write a lisp, when I pick up 2 points, form ground profile, the slope triangle with slope calculate (SLOPE XX%) show on the drawing, the formula for slope is : xx%=∆y/∆x.
I wrote a lisp as below, the result come out as PIC1, but I want result looks as PIC 2, text show SLOPE 36% instead 36.13 I don’t know how to combine the text SLOPE with my calculation 36.13, and how to get rid off the decimal.
(defun c:mcir()
(setvar "cmdecho" 0)
(setq pt1 (getpoint "Enter left Point:"))
(setq px1 (car pt1))
(setq py1 (cadr pt1))
(setq pt2 (getpoint "Enter right Point:"))
(setq px2 (car pt2))
(setq py2 (cadr pt2))
(setq px3 (+ px1 10))
(setq pt3 (list px3 py1))
(setq myb (- px2 px1))
(setq px4 (+ px1 10))
(setq mya (- py2 py1))
(setq myb (- px2 px1))
(setq py4 (+ py1 (* (/ mya myb) 10)))
(setq pt4 (list px4 py4))
(command "pline" pt1 pt3 pt4 "c")
(setq px5 (/ (+ px1 px4) 2))
(setq py5 (/ (+ py1 py4) 2))
(setq pt5 (list px5 py5))
(setq ang (angle pt1 pt2))
(setq ann (/ (* ang 180) 3.14 ))
(setq slp (* 100 (/ mya myb)))
(command "text" pt5 2.5 ann slp)
(prin1)
)
In PIC1, all the red text and dimension are reference.
Thank very much for your help in advance.
Bin
Solved! Go to Solution.