Jump to content

grade or slope percentage


pintseta

Recommended Posts

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. :)

Link to comment
Share on other sites

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)

 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 years later...

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 by CADTutor
Code added to block
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...