(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )

(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )

Anonymous
Not applicable
1,115 Views
4 Replies
Message 1 of 5

(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )

Anonymous
Not applicable

 

 

 

(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )

(princ p1)

(setq p3 (getpoint "\nPick the point  on the screen for the second corner:") )

(princ p3)

 

Hi!

I have a question regarding these commands

 

1) When I run this part of the script

                (setq p1 (getpoint "\nPick the point on the screen for the first corner:") )

The coordinates of entered point are printed.

How do I avoid it?

 

2) When I run the entire script

The coordinates of the first point are printed once

and the coordinates of the second point are printed twice

 Why it works in this way?

Thanks!

  

0 Likes
Accepted solutions (1)
1,116 Views
4 Replies
Replies (4)
Message 2 of 5

Ajilal.Vijayan
Advisor
Advisor
Accepted solution

Hi,

1. LISP will always return the result of last function.

To avoid this, you can use (princ) at the end of each function.

Click the +sign to see the Code

Spoiler
(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )
(setq p3 (getpoint "\nPick the point  on the screen for the second corner:") )
(princ)

Read the Display message functions in LISP.

 

2.The coordinates of first point are printed twice because of (getpoint) function and (princ) function.

Hope this helps.

Message 3 of 5

Anonymous
Not applicable

Thanks!

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

If you trying to get window... then use (getcorner) instead od (getpoint). the result is the same, but you'll see a window on the screen.

 

(setq p1 (getpoint "\nPick the point on the screen for the first corner:") )
(setq p3 (getcorner p1 "\nPick the point on the screen for the second corner:"))
(princ)

 


@Anonymous wrote:

  

2) When I run the entire script

The coordinates of the first point are printed once

and the coordinates of the second point are printed twice

 Why it works in this way?

Thanks!

  


You need to realize that each function returns something. Usually can't see it.... but last one. That's why we usually use (princ) at the end - to print nothing.

 

But this principle is very important to understand.... 

 

(setq pt1 (getpoint))

 

(setq pt2 pr1)

 

is same as... 

 

(setq pt2 (setq pt1 (getpoint))) 

 

 

 

 

 

 

 

Message 5 of 5

Anonymous
Not applicable

Thanks a lot!

0 Likes