Perpendicular line from circle centre

Perpendicular line from circle centre

Philip-John
Advocate Advocate
1,566 Views
4 Replies
Message 1 of 5

Perpendicular line from circle centre

Philip-John
Advocate
Advocate

I need a LISP routine as follows: (see image also)

1. select a line (or any object).
2. select a circle or circles.
.. then a perpendicular line/lines should be drawn from centre of circle/circles to the line.

Please help..

Untitled.png

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

Moshe-A
Mentor
Mentor

@Philip-John hi,

 

do this:

 

Command : line  < start line command>

Specify first point: cen of  <pick circle center point>
Specify next point or [Undo]: per of    <pick the line>

 

also set a fix osnap "cen,per" or make a toolbar macro call it "line per"

 

moshe

0 Likes
Message 3 of 5

Philip-John
Advocate
Advocate

With command I know how to do this..

I requested a lisp routine to do this with two clicks (selection).

1. select the line

2. select circle itself (not circle centre)

0 Likes
Message 4 of 5

dlanorh
Advisor
Advisor
Accepted solution

Try this

(defun c:per2 (/ *error* c_doc ms l_obj ss c_pt l_pt)

	(defun *error* ( msg ) 
		(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
		(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
		(princ)
	);_end_*error*_defun
  
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        ms (vla-get-modelspace c_doc)
  );end_setq 
  (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
  (vla-startundomark c_doc)
  
  (setq l_obj (vlax-ename->vla-object (car (entsel "\nSelect Line/Polyline : "))))
  (prompt "\nSelect Circles : ")
  (setq ss (ssget '((0 . "CIRCLE"))))
  (vlax-for c_obj (vla-get-activeselectionset c_doc)
    (setq c_pt (vlax-get c_obj 'center)
          l_pt (vlax-curve-getclosestpointto l_obj c_pt)
    );end_setq
    (vla-addline ms (vlax-3d-point c_pt) (vlax-3d-point l_pt))
  );end_for
  (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
);end_defun  
  

I am not one of the robots you're looking for

0 Likes
Message 5 of 5

Philip-John
Advocate
Advocate

Thanks a lot dlanorh
It worked..

0 Likes