Point from coordinats

Point from coordinats

GeryKnee
Advocate Advocate
415 Views
5 Replies
Message 1 of 6

Point from coordinats

GeryKnee
Advocate
Advocate

 

To define a 2D point from its coordinates (x,Y),

wrong :

(setq pt1 (pt1X pt1Y))

Which is the right?

0 Likes
Accepted solutions (3)
416 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

(setq Pt (list x y))

Message 3 of 6

Moshe-A
Mentor
Mentor
Accepted solution

@GeryKnee ,

 

say you have this point

(setq pt1 (list 2.0 6.0 0.0))

 

now you want to define a point where y of pt1 is the x of pt2 and the x of pt1 is y of pt2

(setq pt2 (list (cadr pt1) (car pt1) 0.0))

 

of course if it's a 2d point a (reverse) will do

 

Moshe

 

Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

You may be remembering lists that do not start with the word 'list' for the function, such as:

'(1.23 4.56)

Those use the preceding apostrophe, and are called "quoted" lists, because the apostrophe is shorthand for the (quote) function [read about that and (list) in the AutoLisp Reference for the description of this].  BUT that can be used only if everything inside the list is "raw" information not requiring evaluation, such as numbers or text strings.  When you use variables, or other AutoLisp functions, either of which need to be evaluated, you can't do it that way, but must use the explicit (list) function:

(list x y)

(list (getvar 'osmode) (+ 1 2))

Kent Cooper, AIA
Message 5 of 6

calderg1000
Mentor
Mentor

Regards @GeryKnee 

Some examples...

;;;---------------------------------
(setq pt1X 10.5
      pt1Y 20.5
      )
(setq pt1(list pt1X pt1Y))
;;;---------------------------------
(setq pt1 (getpoint"\nPick Point: "))
(setq pt1X (car pt1)
      pt1Y (cadr pt1)
      pt1Z (caddr pt1)
      )
(setq pt1(list pt1X pt1Y pt1Z))
(setq pt1(list (nth 0 pt1) (nth 1 pt1)(nth 2 pt1)))
(setq pt1(append (list(car p) (cadr p))(list(caddr pt1))))

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 6 of 6

Sea-Haven
Mentor
Mentor

Another example of a 2 point rectang, note the use of pt1 as a rubber band indicator in the second point request.

 

(setq pt1 (getpoint "\nPick lower left "))
(setq pt3 (getpoint pt1 "\nPick upper right "))
(setq pt2 (list (car pt3)(cadr pt1)))
(setq pt4 (list (car pt1)(cadr pt3)))
(command "pline" pt1 pt2 pt3 pt4 "C")

 

Happy to help someone trying to learn.