Draw Line under Angle - work bad (bad Angles)

Draw Line under Angle - work bad (bad Angles)

Anonymous
Not applicable
2,825 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,826 Views
22 Replies
Replies (22)
Message 2 of 23

marko_ribar
Advisor
Advisor
(defun c:QNGPOI
 (/ ptL1 ptANG1 ptANG2 Length
  Xpt1 Ypt1 Xpt2 Ypt2 DX DY
  TAN Angle 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 (cadr ptANG1))
 (setq XptANG2 (car ptANG2))
 (setq YptANG2 (cadr 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 Angle Length))
 (command "_LINE" ptL1 ptL2 "")
)

 

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 23

Kent1Cooper
Consultant
Consultant

@marko_ribar wrote:
....
(setq XptANG1 (car ptANG1)) (setq XptANG1 (cadr ptANG1)) (setq XptANG2 (car ptANG2)) (setq YptANG2 (cadr ptANG2)) ....

 


... and I expect you should also change:

....
(setq XptANG1 (car ptANG1))
(setq YptANG1 (cadr ptANG1))
(setq XptANG2 (car ptANG2))
(setq YptANG2 (cadr ptANG2))
....

Kent Cooper, AIA
0 Likes
Message 4 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
....
....
 (/ ptL1 Length Angle ptL2)
....

.... 


By the way, I would strongly suggest that you use variable names other than 'Length' and 'Angle' in all of these routines.  Both are AutoLISP function names, and you could cause yourself problems if those function need to be used.  They're not used in any of these routines, and as localized variables they shouldn't have any effect outside them, but it's just good general practice to avoid using function names, as well as symbols such as T and pi, as variable names.

Kent Cooper, AIA
0 Likes
Message 5 of 23

Anonymous
Not applicable

1.

http://www.afralisp.net/reference/autolisp-functions.php

 

(cadr <LIST>)

Returns the second element of a list.

 

(cdr <LIST>)

Returns all but the first element of a list.

 

cdr returns Y and Z coordinates of a specified point, and that was my error.

I should use cadr to get only Y coordinate.

 

Difference between cadr and cdr is explained on the site

http://www.afralisp.net/autolisp/tutorials/list-manipulation.php

 

2.1.

And what will this next, extended lisp look like?

 

"Specify Length_X to Draw Line: "

"Specify Angle in Degrees to Draw Line: "

(it is just what we made)

 

But  I want to make it extended by this part:

And every time you end drawing one Line,

the program will ask you for specyfing Length_X and Angle to Draw next Line.

"Specify Lenth_X for the next Line: "

"Specify Angle in Degrees for the next Line: "

 

 

2.2.

The same as in 2.1., but you don't specify Angle in Degrees, but Downslope in Percents.

And every time you end drawing one Line,

the program will ask you for specyfing Length_X and Downslope in Percents to Draw next Line.

 

2.3.

Lisp the same as in 2.2., but you specify Downslope as Fraction (Numerator/Dominator):

"Specify Numerator (DeltaY) to define Downslope: "

"Specify Denominator (Delta X) to define Downslope: "

 

Lisp 2.2. is a case of lisp 2.3., because it is case of 2.3. when Denominator is equal to 100.

So the lisp 2.3. is quite more important.

 

On ground of lisp 2.3. we could write lisp 2.2.

 

Lisps 2.1, 2.2 and 2.3 we could easily edit to draw not Line, but Polyline

(in this way we get lisps 3.1, 3.2 and 3.3).

 

I wonder why in Autocad there are not such options defaultly and we have to write lisps to have possibility to use these options.

 

In this way the beginners who dont know about lisps can't draw a line with slope 23/47 so easily.

They have to draw horizontal Line of Length 47, vertical Line of Length 23, draw next Line, this time crosswise, and change its Length.

And the two helping lines (horizontal and vertical) they have to erase from drawing.

 

Imagine how great it would be, if there would be these options by drawing a Line:

you type LINE, Enter, and  there is prompt: "Choose next Point or [Length/ Downslope]: "

when you type L, Enter, there will be "Specify Length value by keyboard or by picking two Points: "

and when you type D, Enter, ther will be prompt "Define Downslope as [Angle/ Fraction/ Percents]: ]

If you type A, Enter, there will be prompt "Specify Angle Units [Degrees/ Radians]: "

Radians are useful, because you could have to draw line under angle of PI/7 radians

(for example you want to draw unit circle in Maths and draw all roots 7-th degree of the number 1.

First root is under the Angle PI/7 to the Horizontal line. If you would have to specify angle of PI/7 in Degrees,

it would be hard, and you are not able to enter accurately result. There will be inaccuracies and the drawing will be bad).

 

The same should be for PLINE.

 

 

 

0 Likes
Message 6 of 23

Anonymous
Not applicable

Thank you, very good advice.

0 Likes
Message 7 of 23

Kent1Cooper
Consultant
Consultant
; 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)
)

 

 

For that an others with similar wrong-angle results:

 

The (polar) function wants radians for its angle argument.

 

(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 (/ pi 2) Length))
 (command "_LINE" ptL1 ptL2)
)

 

Kent Cooper, AIA
0 Likes
Message 8 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

2.1.

And what will this next, extended lisp look like?

 

"Specify Length_X to Draw Line: "

"Specify Angle in Degrees to Draw Line: "

(it is just what we made)

 

But  I want to make it extended by this part:

And every time you end drawing one Line,

the program will ask you for specyfing Length_X and Angle to Draw next Line.

"Specify Lenth_X for the next Line: "

"Specify Angle in Degrees for the next Line: "

.... 


It would look something like this:

 

After selection of the first starting point [ptL1], go into a (while) loop:

 

(while

  (get.... ;; User continues to respond with next piece of information for each Line;;

  (.... ;; process it to draw next Line ... ;;

  (setq ptL1 ptL2) ;; <-- endpoint of previous Line becomes start point of next one

); while

Kent Cooper, AIA
0 Likes
Message 9 of 23

Anonymous
Not applicable

Your "red" advice is a gold advice!

I thought about incrementing index of points by "(setq i (1+ i))", but it looks for me impossible to do it in AutoLisp.

But now, after you gave  me this advice, I can try. And it is very possible that I come up with this. 

0 Likes
Message 10 of 23

Anonymous
Not applicable

I wrote this lisp:

 

; QNG = Line aNGle (multiple segments)
(defun c:QNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (while
  (setq Angle  (getangle "\nTYPE the Angle value OR PICK two Points to define ANGLE: "))
  (setq Length (getdist  "\nTYPE Length of the Line OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Angle Length))
  (command "_LINE" ptL1 ptL2)
  (setq ptL1 ptL2)
 )
)

; From CommandLine:
;Command: QNG
;Specify First Point of Line:
;TYPE the Angle value OR PICK two Points to define ANGLE: 23
;
;TYPE Length of the Line OR PICK two Points to define LENGTH: 21
;
;TYPE the Angle value OR PICK two Points to define ANGLE: 45
;
;TYPE Length of the Line OR PICK two Points to define LENGTH: 35
;
;Point or option keyword required.
;; error: Function cancelled

 

But it doesn't work. Please, tell me, what I made wrong.

 

0 Likes
Message 11 of 23

Anonymous
Not applicable

I soluted my problem. Thank you all. Now I can use one the most wanted by me lisps.

(defun c:QNG2
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (while
  (setq Angle  (getangle "\nTYPE the Angle value OR PICK two Points to define ANGLE: "))
  (setq Length (getdist  "\nTYPE Length of the Line OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Angle Length))
  (command "_LINE" ptL1 ptL2 "") ; I added "" and now it works
  (setq ptL1 ptL2)
 )
)

And here is the next lisp. It is the same, but for Polyline:

 

(defun c:QQNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline: "))
 (while
  (setq Angle  (getangle "\nTYPE the Angle value OR PICK two Points to define ANGLE: "))
  (setq Length (getdist  "\nTYPE Length of the Polyline Segment OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Angle Length))
  (command "_PLINE" ptL1 ptL2 "")
  (setq ptL1 ptL2)
 )
)

 

But it draws multiple Polylines. They don't make one Polyline.

How can I make one Polyline?

In the lisp, I should order to select these Polylines and JOIN them.

In every loop of (while) function, should l save the newly created Polyline to a list? Then, by the (ssget), I would load all these Polylines from this list in order to select them. And I would use JOIN on them.

Is it good idea or there are better ideas?

0 Likes
Message 12 of 23

Kent1Cooper
Consultant
Consultant

[Now I see you figured this out already, but I don't see an option to delete my Reply....]

 

The Line command needs to be ended:

 

  (command "_LINE" ptL1 ptL2 "")

Kent Cooper, AIA
0 Likes
Message 13 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

And here is the next lisp. It is the same, but for Polyline:

 

(defun c:QQNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline: "))
 (while
  (setq Angle  (getangle "\nTYPE the Angle value OR PICK two Points to define ANGLE: "))
  (setq Length (getdist  "\nTYPE Length of the Polyline Segment OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Angle Length))
  (command "_PLINE" ptL1 ptL2 "")
  (setq ptL1 ptL2)
 )
)

 

But it draws multiple Polylines. They don't make one Polyline.

How can I make one Polyline?

....


You would need to have the (while) loop inside the (command) function to remain in the Polyline command between points.  Something like this [untested]:

 

(defun c:QQNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline: "))
(command "_.pline" ptL1); re-located earlier (while ; inside Polyline command (setq Angle (getangle ptL1 "\nTYPE the Angle value OR PICK to define ANGLE: ")); omitted "two Points" (setq Length (getdist "\nTYPE Length of the Polyline Segment OR PICK two Points to define LENGTH: ")) (setq ptL2 (polar ptL1 Angle Length)) (command ptL2)); feed new point out to Polyline command (setq ptL1 ptL2) ); while
(command "")); end Polyline command )

 

It assumes in the (getangle) function that you would always want to pick the angle relative to the previous point, rather than by picking two independent points, but that can be changed back.

 

It would need to be done a little differently if you might sometimes want to use the Close option.  [And I would still change those variable names....]

Kent Cooper, AIA
0 Likes
Message 14 of 23

Anonymous
Not applicable

And have you any idea what to do to get one Polyline not multiple Polylines as result of QQNG?

0 Likes
Message 15 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

And have you any idea what to do to get one Polyline not multiple Polylines as result of QQNG?


[See my previous Reply -- I think we "crossed in the mail."]

Kent Cooper, AIA
0 Likes
Message 16 of 23

Anonymous
Not applicable

There is a problem.

When I use my QNG lisp, and when there is prompt "TYPE Length... ", I press Enter.

And then in CommandLine appeares as follows:

 

Command: QNG
Specify First Point of Line:
TYPE the Angle value OR PICK two Points to define ANGLE: Specify second point:
TYPE Length of the Line OR PICK two Points to define LENGTH:
no function definition: CD:SYS_UNDOEND

 

This is my code. What can be wrong? Do I have forgotten something important?

 

; QNG = Line aNGle (multiple segments)
(defun c:QNG
 (/ ptL1 Length Angle ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (while
  (setq Angle  (getangle "\nTYPE the Angle value OR PICK two Points to define ANGLE: "))
  (setq Length (getdist  "\nTYPE Length of the Line OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Angle Length))
  (command "_LINE" ptL1 ptL2 "")
  (setq ptL1 ptL2)
 )
)

 

 

0 Likes
Message 17 of 23

hmsilva
Mentor
Mentor

@Anonymous wrote:

There is a problem.

...

 CD:SYS_UNDOEND

 

This is my code. What can be wrong? Do I have forgotten something important?

 

 


CD:SYS_UNDOEND is a function from CADPL library, and has nothing to do with this code...

 

Henrique

EESignature

0 Likes
Message 18 of 23

Anonymous
Not applicable

Yes, we "crossed the mail.

Thank you, man! You are great!

At last I can use one the best lisp I dreamed of.

 

Your lisp was good, I draw Plyline ABCDE... wih this lisp.

But when I type Angle and Length for Points C, D, E, etc., cursor stays every time in point A.

That is not big problem; that's not a bad  error. It is just visually unwanted thing.

 

So I add one little change, and now it stays in last drawn Point.

That means, when I specify Angle and Length to draw Segment BC, cursor stays in Point B, not in Point A.

 

And I changed names of these variables. You are absolutelly right.

 

Thank you very much for all you help.

 

(defun c:QQNG
 (/ ptL1 Len Ang ptL2)
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Polyline: "))
 (command "_.pline" ptL1); re-located earlier
 (while ; inside Polyline command
  (setq Ang  (getangle ptL1 "\nTYPE the Angle value OR PICK to define ANGLE: ")); omitted "two Points"
  (setq Len (getdist  "\nTYPE Length of the Polyline Segment OR PICK two Points to define LENGTH: ")) 
  (setq ptL2   (polar ptL1 Ang Len))
  (command ptL2)
;); feed new point out to Polyline command
  (setq ptL1 ptL2)
 ); while
 (command "")); end Polyline command
)

 

 

Now on ground of this lisp I can write lisp, in which there will be not Angle, but Downslope as Fraction and Downslope in Percents,

and I will be in seventh heaven.

0 Likes
Message 19 of 23

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.....

 

(defun c:QQNG
...
  (command ptL2)
;); feed new point out to Polyline command
  (setq ptL1 ptL2)
 ); while
 (command "")); end Polyline command
)

....


I'm not surprised at that excess right parenthesis -- something really wacky was going on as I was trying to post message 13 [when I made red things bold, they disappeared completely] and tried several replacements and changes to try to get things to appear, and I couldn't tell whether characters might actually still be in there but somehow turned white so I couldn't see them, or whether they would appear again when posted.  The same effect also happened on that last (command) line, which should also have the second right parenthesis [both excess ones are bold, left over from from the wackiness] removed:

(command ""); end Polyline command

Kent Cooper, AIA
0 Likes
Message 20 of 23

Anonymous
Not applicable

On ground of what we get for now, I wrote next lisp

; QDFV = Line Downslope (as Fraction) Vertical
; QDFY = Line Downslope (as Fraction) (Y=v)ertical
(defun c:QDFY
 (/ ptL1 Len_Y
  Delta_X Delta_Y
  DownslopeFraction
  Len_X Len
  Ang ptL2
 )
 (setvar "cmdecho" 0)
 (setq ptL1   (getpoint "\nSpecify First Point of Line: "))
 (command "_LINE" ptL1)
 (while
  (setq Delta_Y  (getdist  "\nTYPE DELTA_Y value, OR PICK two Points to define it: "))
  (setq Delta_X  (getdist  "\nTYPE DELTA_X value, OR PICK two Points to define it: "))
  (setq DownslopeFraction  (/ Delta_Y Delta_X))
  (setq Len_Y (getdist  "\nTYPE Length_Y of the Line, OR PICK two Points to define it: ")) 
  (setq Len_X (* (/ 1 DownslopeFraction) Len_Y))
  (setq Len
   (sqrt
    (+ (* Len_X Len_X) (* Len_Y Len_Y))
   ); sqrt
  ); Len
  (setq Ang (atan Len_Y Len_X)); Ang = atan(Len_Y/Len_X) = atan(Delta_Y/Delta_X)
  (setq ptL2 (polar ptL1 Ang Len))
  (command ptL2)
  (setq ptL1 ptL2)
 ); while
);defun

 

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?

0 Likes