Draw Line. Specify Horizontal Length[nr,Pt1-Pt2] and Downslope [%,N/D,Ang]

Draw Line. Specify Horizontal Length[nr,Pt1-Pt2] and Downslope [%,N/D,Ang]

Anonymous
Not applicable
1,209 Views
6 Replies
Message 1 of 7

Draw Line. Specify Horizontal Length[nr,Pt1-Pt2] and Downslope [%,N/D,Ang]

Anonymous
Not applicable

Hello,
I really often have to draw line
which's horizontal (or vertical) dimension should be for example 500 mm
and the angle of this line is such, that i=2/3.
Or, let's say, 36.5%. Or simply the angle should be 43.2 degrees.

1.
How to draw it the fastest way without lisp?

2.
I wil be thankful if somebody write such lisp:
"Specify length in horizontal/ vertical or [Points]: "
And here you can type the value by keyboard
or determine length by picking two points.
And then "Specify downslope by it's value in Percents or [Fraction/ Angle]: "
Or, what I prefer:
"Specify, which way you will express downslope's value [Percents/Fraction/ Angle]: "
(Now you press P, F, or A, and Enter and you have one of these three prompts:)
"Specify (Express) the downslope's value in Percents: "
"Specify (Express) the downslope's value by Fraction: "
Here you can type for example "37/45", by using "/"
If it will be not possible, there will be two commands:
"Specify numerator (above line): "
"Specify denominator (under line): "
and the last option:
"Specify (Express) the downslope's value by Angle in Degrees: "
*downslope = spadek terenu in Polish. I don't know if I use right word in English.
*I am not sure if "line" is right word for this dash between numerator and denominator.
I would be thankful if somebody will write this lisp and it will be working properly.

0 Likes
1,210 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Better would be such lisp:

 

After you draw every next Segment of Line/ Polyline, there will be these questions:

"What to draw? [Line/ PLine]: "
"Define Slope by [Angle/ Fraction/ Downlope (%)]: "

 

  "Specify the Numerator (type value or pick two Points): "

  "Specify the Denominator (type value or pick two Points): "

 

  "Specify the Angle in Degrees: "

 

  "Specify Downslope in Percents: "

 

"What Length do you want to specify? [LX/ LY/ L]: "
"Specify LX (type value or pick two Points): "

0 Likes
Message 3 of 7

Anonymous
Not applicable

I made three lisps:

 

; "What to draw? [Line/ PLine]: "
; "Define Slope by [Angle/ Fraction/ Downlope (%)]: "
;  "Specify the Numerator (type value or pick two Points): "
;  "Specify the Denominator (type value or pick two Points): "
;  "Specify the Angle in Degrees: "
;  "Specify Downslope in Percents: "
; "What Length do you want to specify? [LX/ LY/ L]: "
;  "Specify LX (type value or pick two Points): "

;---
; QHD = Line Horizontal Downslope[%]
; QXD = Line (X=h)orizontal Downslope[%]
; D2R = Degrees TO Radians
(defun c:QXDD2R
 (/ ptL1 Length_X
  DownslopePercents
  Length_Y
  Degrees->Radians
  Angle ptL2
 )
 (setvar "cmdecho" 0)
 (setq ptL1     (getpoint "\nSpecify First Point of Line: "))
 (setq Length_X (getdist  "\nType value of Length_X (Horizontal) of the Line or Pick two Points to define this Length: "))
 (setq DownslopePercents  (getreal "\nType the Downslope value (in Percents) or Pick two Points to define Downslope (in Percents): "))
 (setq Length_Y (* (/ DownslopePercents 100) Length_X))
 (setq Length
  (sqrt
   (+
    (* Length_X Length_X)
    (* Length_Y Length_Y)
   ); +
  ); sqrt
 ); Length
 (setq Angle  (atan Length_Y Length_X))
;-----------
(defun Degrees->Radians (numberOfDegrees) 
 (* pi (/ numberOfDegrees 180.0))
)
;-----------
 (setq ptL2
  (polar
   ptL1
  (Degrees->Radians Angle)
   Length_X
  )
 )
 (command "_LINE" ptL1 ptL2)
)

; I typed Length_X = 100 and Downslope = 2(%)
; This command created Line which has:
; Length = 100, Delta X = 100, Delta Y = 0.0349,
; Angle = 0
;--------------------------------------------
;--------------------------------------------
; QHD = Line Horizontal Downslope[%]
; QXD = Line (X=h)orizontal Downslope[%]
; R2D = Radians TO Degrees
(defun c:QXDR2D
 (/ ptL1 Length_X
  DownslopePercents
  Length_Y
  Radians->Degrees
  Angle ptL2
 )
 (setvar "cmdecho" 0)
 (setq ptL1     (getpoint "\nSpecify First Point of Line: "))
 (setq Length_X (getdist  "\nType value of Length_X (Horizontal) of the Line or Pick two Points to define this Length: "))
 (setq DownslopePercents  (getreal "\nType the Downslope value (in Percents) or Pick two Points to define Downslope (in Percents): "))
 (setq Length_Y (* (/ DownslopePercents 100) Length_X))
 (setq Length
  (sqrt
   (+
    (* Length_X Length_X)
    (* Length_Y Length_Y)
   ); +
  ); sqrt
 ); Length
 (setq Angle  (atan Length_Y Length_X))
;-----------
(defun Radians->Degrees (numberOfRadians)
 (* 180.0 (/ numberOfRadians pi))
)
;-----------
 (setq ptL2
  (polar
   ptL1
  (Radians->Degrees Angle)
   Length_X
  )
 )
 (command "_LINE" ptL1 ptL2)
)

; I typed Length_X = 100 and Downslope = 2(%)
; This command created Line which has:
; Length = 100, Delta X = 41.2351, Delta Y = 91.1025,
; Angle = 66
;--------------------------------------------------
;--------------------------------------------
; QHD = Line Horizontal Downslope[%]
; QXD = Line (X=h)orizontal Downslope[%]
(defun c:QXD
 (/ ptL1 Length_X
  DownslopePercents
  Length_Y
  Angle ptL2
 )
 (setvar "cmdecho" 0)
 (setq ptL1     (getpoint "\nSpecify First Point of Line: "))
 (setq Length_X (getdist  "\nType value of Length_X (Horizontal) of the Line or Pick two Points to define this Length: "))
 (setq DownslopePercents  (getreal "\nType the Downslope value (in Percents) or Pick two Points to define Downslope (in Percents): "))
 (setq Length_Y (* (/ DownslopePercents 100) Length_X))
 (setq Length
  (sqrt
   (+
    (* Length_X Length_X)
    (* Length_Y Length_Y)
   ); +
  ); sqrt
 ); Length
 (setq Angle  (atan Length_Y Length_X))
 (setq ptL2
  (polar
   ptL1
   Angle
   Length_X
  )
 )
 (command "_LINE" ptL1 ptL2)
)

; I typed Length_X = 100 and Downslope = 2(%)
; This command created Line which has:
; Length = 100, Delta X = 99.98, Delta Y = 1.9996,
; Angle = 1
;--------------------------------------------------

 , but only QXD lisp works almost properly.

 

To check if they work well, with every of this lisp I drew a line, by typin Length_X = 100 and Downslope = 2 %.

I don't know why, but in every of these three lisps, finally Length was equal 100, not Length_X.

QXD gived the best  result -  Length_X = 99,98 (but should 100) and Length_Y = 1.996 (but should 2).

 

Why there are inaccuracies? Maybe inaccuracy of Length cames from L = sqrt[ (L_X)^2 + (L_Y)^2]?

 

Could somebody help me?

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

 (setq ptL2

....
  (polar
   ptL1
   Angle
   Length_X
  )
)
(command "_LINE" ptL1 ptL2)
)

....

with every of this lisp I drew a line, by typin Length_X = 100 and Downslope = 2 %.

I don't know why, but in every of these three lisps, finally Length was equal 100, not Length_X.

....

 

Why there are inaccuracies? ....


Because you asked for the Line to be Length_X long, and Length_X is still 100.  Use Length [which you calculated, but did not use] instead of Length_X in the part of the code quoted above.

Kent Cooper, AIA
0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

....
 (setq DownslopePercents  (getreal "\nType the Downslope value (in Percents) or Pick two Points to define Downslope (in Percents): "))
....

....


The (getreal) function doesn't allow picking two points on-screen.  If you want that option, use (getdist) as you did when setting Length_X.  But I wonder about the usefulness of that option.  If the user wants a 2% slope, they would need to pick two points 2 drawing units apart, which might be pretty impossible if zoomed out far enough in relation to the sizes of things, or if Snap is not on and at a reasonable value for such picks.  Would anyone choose to do it that way, when they can just type in 2?

Kent Cooper, AIA
0 Likes
Message 6 of 7

Anonymous
Not applicable

Your thinking is good. I think the same, but generally in life there are situations which surprised us.

If there is possibility to define Downslope by picking two Points, just in case it's better to use it.

When I have choise between two options:

1. to enter Downslope value by keybord or by picking two Points

2. to enter Downslope value only by keybord

I prefer to use option 1.

 

Of course, most of the users the most times will choose the options with specifing the value by keyboard.

But you never know if you will have to use this option with picking two Points.

For example, you have Spline, on it there are Points A and B.

And you have to draw Line of Length 36 parallel to Segment AB.

You will not calculate the Downslope of Segment AB, you will rather pick Points A and B.

And for such special cases I prefer to have this additional option with picking two Points.

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

If there is possibility to define Downslope by picking two Points, just in case it's better to use it.

....



The (getangle) function is probably what you want.  It will take either a typed-in angle [in whatever angle format is current -- it will convert it to radians] or two points.  Read about it, and note the [pt] argument that can feed in the first point for you.

Kent Cooper, AIA
0 Likes