Draw Line under Angle - work bad (bad Angles)

Draw Line under Angle - work bad (bad Angles)

Anonymous
Not applicable
2,833 Views
22 Replies
Message 1 of 23

Draw Line under Angle - work bad (bad Angles)

Anonymous
Not applicable
Hello, I made such lisps to draw under angle specified by two points, or like in Otho mode:
;Command: QNGPOI
;Specify First Point of Line:
;Specify First Point to define Angle:
;Specify Second Point to define Angle:
;Specify Length of the Line: 23
;; error: bad argument type: numberp: (-298.858 0.0)

; QNGPOI = line aNGle POInts
(defun c:QNGPOI
 (/ ptL1 ptANG1 ptANG2 Length
  Xpt1 Ypt1 Xpt2 Ypt2 DX DY
  TAN Angle Radians->Degrees ptL2
 )
 (setq ptL1    (getpoint "\nSpecify First Point of Line: "))
 (setq ptANG1  (getpoint "\nSpecify First Point to define Angle: "))
 (setq ptANG2  (getpoint "\nSpecify Second Point to define Angle: "))
 (setq Length  (getreal  "\nSpecify Length of the Line: "))
 (setq XptANG1 (car ptANG1))
 (setq XptANG1 (cdr ptANG1))
 (setq XptANG2 (car ptANG2))
 (setq YptANG2 (cdr ptANG2))
 (setq DX      (- XptANG2 XptANG1))
 (setq DY      (- YptANG2 YptANG1))
 (setq TAN     (/ DY DX))
; If XptANG1 = XptANG2 --> DX = 0, the angle is equal to 90 degrees
; But in CommandLine probably will be error (dividing by 0 in TAN)
 (setq Angle   (atan TAN))
 (defun Radians->Degrees (numberOfRadians)
  (* 180.0 (/ numberOfRadians pi))
 )
 (setq ptL2    (polar ptL1 (Radians->Degrees (Angle)) Length))
 (command "_LINE" ptL1 ptL2)
)
;----
; Zawsze rysuje linie pod kątem 0 stopni
(defun c:QNGD2R
 (/ ptL1 Length Angle Degrees->Radians ptL2)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq Angle  (getangle "\nType the Angle value or Pick two Points to define Angle: "))
 (defun Degrees->Radians (numberOfDegrees) 
  (* pi (/ numberOfDegrees 180.0))
 )
 (setq ptL2   (polar ptL1 
 (Degrees->Radians Angle)
 Length))
 (command "_LINE" ptL1 ptL2)
)
;---
(defun c:QNGR2D
 (/ ptL1 Length Angle Radians->Degrees ptL2)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq Angle  (getangle "\nType the Angle value or Pick two Points to define Angle: "))
 (defun Radians->Degrees (numberOfRadians)
  (* 180.0 (/ numberOfRadians pi))
 )
 (setq ptL2   (polar ptL1 
(Radians->Degrees Angle)
 Length))
 (command "_LINE" ptL1 ptL2)
)
;---
(defun c:QNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq Angle  (getangle "\nType the Angle value or Pick two Points to define Angle: "))
 (princ "\nAngle is equal to: ") Angle
 (setq ptL2   (polar ptL1 Angle Length))
 (command "_LINE" ptL1 ptL2)
)
;---
;QQSEGNG = polyline SEGment aNGle
(defun c:QQSEGSNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline Segment: "))
 (setq Length (getdist  "\nType Length of the Polyline Segment or Pick two Points to define Length: "))
 (setq Angle  (getangle "\nType the Angle value or Pick two Points to define Angle: "))
 (princ "\nAngle is equal to: ") Angle
 (setq ptL2   (polar ptL1 Angle Length))
 (command "_PLINE" ptL1 ptL2)
)
;----------
(defun c:QNGH
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 0 Length))
 (command "_LINE" ptL1 ptL2)
)
;---
;QQSEGNGH = polyline SEGment aNGle 0
(defun c:QQSEGSNGH
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline Segment: "))
 (setq Length (getdist  "\nType Length of the Polyline Segment or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 0 Length))
 (command "_PLINE" ptL1 ptL2)
)
;----------
; Napraw
; Doesn't work properly
; Draws with Angle = 117, not 90
(defun c:QNGT
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 90 Length))
 (command "_LINE" ptL1 ptL2)
)
;---
;QQSEGNGT = polyline SEGment aNGle 90
(defun c:QQSEGSNGT
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline Segment: "))
 (setq Length (getdist  "\nType Length of the Polyline Segment or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 90 Length))
 (command "_PLINE" ptL1 ptL2)
)
;----------
; Napraw
; Doesn't work properly
; Draws with Angle = 233, not 180
(defun c:QNGF
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (defun Radians->Degrees (numberOfRadians)
  (* 180.0 (/ numberOfRadians pi))
 )
 (setq ptL2   (polar ptL1 (Radians->Degrees 180) Length))
 (command "_LINE" ptL1 ptL2)
)
;---
;QQSEGNGF = polyline SEGment aNGle 180
(defun c:QQSEGSNGF
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline Segment: "))
 (setq Length (getdist  "\nType Length of the Polyline Segment or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 180 Length))
 (command "_PLINE" ptL1 ptL2)
)
;----------
; Napraw
; Doesn't work properly
; Draws with Angle = 350, not 270
(defun c:QNGB
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (setq Length (getdist  "\nType Length of the Line or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 270 Length))
 (command "_LINE" ptL1 ptL2)
)
;---
;QQSEGNGT = polyline SEGment aNGle 270
(defun c:QQSEGSNGB
 (/ ptL1 Length ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline Segment: "))
 (setq Length (getdist  "\nType Length of the Polyline Segment or Pick two Points to define Length: "))
 (setq ptL2   (polar ptL1 270 Length))
 (command "_PLINE" ptL1 ptL2)
)
;----------

 

Why the QNGPOI lisp doesn't work?

Why the other lisps draw Line under unproperly Angle?
Please, help me.

 

0 Likes
2,834 Views
22 Replies
Replies (22)
Message 21 of 23

Anonymous
Not applicable

I noticed that there is the second problem.


When there is prompt "Type Delta_Y value ..." and I hit Enter (by accident or not),
I go out of this command and I am in the "normally", default n Autocad, LINE command.


In order to prevent for this situation I want to add something to my lisp.


I want to get this situation:
When there is prompt "Type Delta_Y value ..." and I hit Enter,
I don't go out of this command, but this prompt appears once more.
And if I press Enter once more, this prompt would be once again in CommandLine.
I have to type some value.

 

But this doesn't mean that I have to type all the required values to go out of this command.
When I will see prompt "Type Delta_Y value ...", and I want to go out of this command, I simply press [Esc] button.

 

Please, give me answer: What should I additionally type in this lisp to make such situation as I described?

0 Likes
Message 22 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

When I pick first point (let's call it A), type Delta_Y and Delta_X, then type Length_Y, there is next point (let's call it B) created.

And now it is something strange. You move your mouse and the Dinamic Line Preview is not available.

 

Normally, when you type LINE, Enter, and you draw Line AB, and you move the mouse, the Preview of Line will be to watch.

But in my case, in this lisp, it is left.

Why it is so?


Because you are not in the Line command's prompt, but in a (getdist) function at the time.  Read about that function in Help -- you can get the rubber-band there by using the [pt] argument:

 

  (setq Len_Y (getdist ptL1 "\nTYPE Length_Y of the Line, ...

 

if you want the first point as the basis [change the prompt so it doesn't talk about picking two points].

Kent Cooper, AIA
0 Likes
Message 23 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....
When there is prompt "Type Delta_Y value ..." and I hit Enter (by accident or not),
I go out of this command and I am in the "normally", default n Autocad, LINE command.

....
I want to get this situation:
When there is prompt "Type Delta_Y value ..." and I hit Enter,
I don't go out of this command, but this prompt appears once more.
....


Read about the (initget) function.  It has the ability to prevent the User from hitting Enter in response to a (get...) function prompt.

Kent Cooper, AIA
0 Likes