pintseta Posted May 9, 2016 Share Posted May 9, 2016 hi, i'm looking for lisp that could calculate the grade percentage of a polyline, or 2 points. i'm doing it manually now by measuring the polyline by DIST, and the dividing the delta Y by delta x. it doesn't need to necessarily calculate the percent itself, i'm fine with just the decimal fraction. also it doesn't matter if the result will be in the command line or in inserted text. i would be grateful for that, i'm looking everywhere and i cant even find some routine to modify with my limited knowledge of writing lisps. 1 Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted May 9, 2016 Share Posted May 9, 2016 Take a look: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/grade-or-slope-lisp-routine/td-p/2172103 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/label-slope-between-two-points/td-p/2604319 1 Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted May 9, 2016 Share Posted May 9, 2016 I think OP want this with LWPOLYLINE... Look here : http://www.cadtutor.net/forum/showthread.php?85501-Need-help-to-get-slope-polylines-2D&p=#5 HTH, M.R. 1 Quote Link to comment Share on other sites More sharing options...
pintseta Posted May 9, 2016 Author Share Posted May 9, 2016 well thank you both for the quick reply. i tried all the options you linked and so far the closest routine for what i need is GRADE. but it needs some changes - lets say i have polyline with 2% grade, delta y=0.1m, delta x=5m. the lisp will results with the text 50:1. i want the routine to discard the ":1" (which i think i know how to do), and divide 100 with the "50" (or any other results) with one decimal place accuracy. so the result in this case will be "2.0". I would greatly appreciate your help p.s. for anyone who copying the routine, notice that your default text style height is greater then 0.00, otherwise it wont work. (defun c:grade () (prompt "\npick points for the grade") (setq ang1 (getangle)) (setq tanofang (/ (sin ang1) (cos ang1))) (setq grade1 (/ 1 tanofang)) (setq txt1 (strcat (rtos grade1 2 1) ":1")) ;;delete this? ;; (setq pnt1 (getpoint "\nPick location for text")) (command "text" pnt1 (rtd ang1) txt1) ) (defun rtd (a) (/ (* a 180.0) pi) )(defun c:grade () (prompt "\npick points for the grade") (setq ang1 (getangle)) (setq tanofang (/ (sin ang1) (cos ang1))) (setq grade1 (/ 1 tanofang)) (setq txt1 (strcat (rtos grade1 2 1) ":1")) (setq pnt1 (getpoint "\nPick location for text")) (command "text" pnt1 (rtd ang1) txt1) ) (defun rtd (a) (/ (* a 180.0) pi) 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 10, 2016 Share Posted May 10, 2016 Your actually not measuring grade this would imply for me a vertical slope Z, rather your reflecting a plane angle as a 1 in or a percent. You can also do say cross section slopes which have been plotted as 2d but take into account the difference in scale factor again as 1 in or percent. 1 Quote Link to comment Share on other sites More sharing options...
MARUEL B. BELAZA Posted July 2, 2019 Share Posted July 2, 2019 (edited) I hope this code will help you, it will get the percentage of the slope of two point, refer to the previous code that i get. have a great day (defun c:grade () (prompt "\nPick points for the grade") (setq ang1 (getangle)) (setq tanofang (/ (cos ang1) (sin ang1))) (setq grade1 (/ 100 tanofang)) (setq txt1 (strcat (rtos grade1 2 2) "%")) (setq pnt1 (getpoint "\nPick location for text")) (command "text" pnt1 "0.00" txt1) ) Edited July 3, 2019 by CADTutor Code added to block 1 Quote Link to comment Share on other sites More sharing options...
CADTutor Posted July 3, 2019 Share Posted July 3, 2019 @MARUEL B. BELAZA That's very similar to the code from pintseta. What more does yours add? 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.