How to convert 3D point to 2D

How to convert 3D point to 2D

luizhcastanho
Contributor Contributor
526 Views
4 Replies
Message 1 of 5

How to convert 3D point to 2D

luizhcastanho
Contributor
Contributor

 

(defun c:test ( / p1 p2 )  
    (if (setq p1 (getpoint "\nSpecify Basepoint: "))
        (while (member (car (setq p2 (grread t 15 0))) '(5 2))
            (redraw) 
            (if (listp (setq p2 (cadr p2)))
                (grdraw p1 (LM:OrthoPoint p1 p2) -1 1)
                (if (= 15 p2)
                    (setvar 'ORTHOMODE (- 1 (getvar 'ORTHOMODE)))
                )
            )
        )
    )
  ;(set ang (angle (nth 0 (nth 1 p1)) (nth 0 (nth 1 p2)) ))
    (redraw)

 (setq pt1 (list (nth 0 p1) (nth 1 p1)))
 
 (setq pt2 (list (nth 0 p2) (nth 1 p2)))
	 
 (setq ang (* (angle pt1 pt2) (/ 180 pi)))
  
)

 

0 Likes
527 Views
4 Replies
Replies (4)
Message 2 of 5

pendean
Community Legend
Community Legend
3D Point?
0 Likes
Message 3 of 5

luizhcastanho
Contributor
Contributor

The LM:OrthoPoint function returns p1 and p2 in 3d point

 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

Is there a question?

 

Every "point" [assuming you mean a location, not a Point object] in AutoCAD is 3D.  You may choose to ignore the Z coordinate, and you can remove it from a point coordinate list if you want to, leaving just the X & Y coordinates, in a couple of ways.  If 3DPoint is an XYZ point coordinate list:

 

(setq 2Dpoint (reverse (cdr (reverse 3DPoint))))

or

(setq 2Dpoint (list (car 3DPoint) (cadr 3DPoint)))

 

Is this topic about something like that?  If not, explain in more detail.

Kent Cooper, AIA
0 Likes
Message 5 of 5

john.uhden
Mentor
Mentor

@Kent1Cooper ,

I think it was you who gets the credit for having pointed out a 3rd method...

(setq 2dpoint (mapcar '* '(1 1) 3dpoint))
or
(setq 2dpoint (mapcar '+ '(0 0) 3dpoint))

Thank you for that.  I like it. 

John F. Uhden

0 Likes