18
78
61
初露锋芒
; Grade ; ; by Robert Condon ; 13/9/12 ; ; ; To use: Select two points from left to ; right and it will give you the ; grade between the points ; ; ; (defun c:grd ()(setq p1 (getpoint "\n1st point of Grade:"))(setq p1X (car p1))(setq p1Y (cadr p1))(setq p2 (getpoint "\n2nd point of Grade:"))(setq p2X (car p2))(setq p2Y (cadr p2))(setq rise (- p2Y p1Y))(setq run (- p2X p1X))(setq textposY (float (if(> (+ p1Y p2Y) 0) (/ (+ p1Y p2Y) 2 ) (setq textdisp 0) )))(setq textposX (float(/ (+ p1X p2X) 2 )))(setq textpos (list textposX textposY 0.0))(setq trot (angle p1 p2))(if (> rise 0) (progn (setq rise1a (/ run rise) ) (setq rise1 (rtos(/ run rise) ) ) ) ) (if (< rise 0) (progn (setq rise1a (/ run rise) ) (setq rise1 (rtos(/ run rise) ) ) ) )(if (> run 0)(setq grade (rtos(* 100 (/ rise run)) ) ) ) (if (< run 0)(setq grade (rtos(* 100 (/ rise run)) ) ) )(if (>= 9.999 rise1a) (setq textdisp (strcat "[url="file://\\pxsa1.4286"]\\pxsa1.4286[/url];" rise1 ":1")) (setq textdisp (strcat "[url="file://\\pxsa1.4286"]\\pxsa1.4286[/url];" grade "%")) )(if (progn (> 1 rise1a)(< 0 rise1a) )(setq textdisp (strcat "[url="file://\\pxsa1.4286"]\\pxsa1.4286[/url];" "1:" (rtos(* rise1a 100) ) )) )(if (progn (< -1 rise1a)(> 0 rise1a) )(setq textdisp (strcat "[url="file://\\pxsa1.4286"]\\pxsa1.4286[/url];" "1:" (rtos(* rise1a 100) ) )) ) (if (= rise 0) (progn (setq textdisp "")(princ "\nGrade is flat")) ) (if (= run 0) (progn (setq textdisp "")(princ "\nGrade is vertical") ) );(setq text size (getint "Text size: "))(entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") '(100 . "AcDbMText") (cons 10 textpos) '(40 . 0.5) '(41 . 0) '(71 . '(72 . 5) (cons 1 textdisp) '(7 . "ISO3098B") '(210 0.0 0.0 1.0) '(11 1.0 0.0 0.0) '(42 . 0.833333) '(43 . 4.66667) (cons 50 trot) '(73 . '(44 . 1.0)))