Jump to content

Recommended Posts

Posted

i have to get the coordinates of common (outer) tangents of two circles.

c1= '(0 0)
c2='(0 15)
r1 =12.5
r2=5
;c1 and c2 centers
;r1 and r2 radius

 

pls help me.

Posted
 
(defun C:Go ()
  (vl-load-com)
  (setvar 'Osmode 512)
  (while (not (setq 1st (entsel "Select first circle: "))))
  (while (not (setq 2nd (entsel "Select second circle: "))))
  (setq 1st (osnap (last 1st) "_Nea"))
  (setq 2nd (osnap (last 2nd) "_Nea"))
  (command "_.LINE" "_Tan" 1st "_Tan" 2nd "")
  (setq line (entget (entlast)))
  (princ
     (strcat
        "\nCoords:\t\t"
        (vl-princ-to-string (cdr (assoc 10 line)))
        "\t"
        (vl-princ-to-string (cdr (assoc 11 line)))
     )
  )
  (entdel (entlast))
)

Posted

How about using some geometry... (similar to my post here).

 

(defun LM:2CircleTangents ( c1 r1 c2 r2 / d1 d2 tan ang )

 (if (< (abs (setq d1 (- r1 r2))) (setq d2 (distance c1 c2)))
   (progn
     (setq tan (atan (sqrt (- (* d2 d2) (* d1 d1))) d1)
           ang (angle c1 c2)
     )
     (list
       (list (polar c1 (+ ang tan) r1) (polar c1 (- ang tan) r1))
       (list (polar c2 (+ ang tan) r2) (polar c2 (- ang tan) r2))
     )
   )
 )
)

 

Test function:

 

(defun c:test ( / cir1 cir2 )
 (if
   (and
     (setq cir1 (car (entsel "\nSelect First Circle: ")))
     (eq "CIRCLE" (cdr (assoc 0 (setq cir1 (entget cir1)))))
     (setq cir2 (car (entsel "\nSelect Second Circle: ")))
     (eq "CIRCLE" (cdr (assoc 0 (setq cir2 (entget cir2)))))
   )
   (apply 'mapcar
     (cons '(lambda ( a b ) (entmakex (list (cons 0 "LINE") (cons 10 a) (cons 11 b))))
       (LM:2CircleTangents
         (cdr (assoc 10 cir1)) (cdr (assoc 40 cir1))
         (cdr (assoc 10 cir2)) (cdr (assoc 40 cir2))
       )
     )
   )
 )
 (princ)
)

Posted

In the past I extended this idea and used a grRead construct (not practical, but fun to use/write):

 

Cam.gif

 

The code for the above is attached and will work in all UCS/Views and has no dependence on Visual LISP.

 

This was the final product:

 

Belt.gif

 

Lee

2CircleDynTangents.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...