kalai 发表于 2022-7-6 09:24:47

获取普通唐的坐标

我必须得到两个圆的公共(外)切线的坐标。

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

 
请帮帮我。

Ahankhah 发表于 2022-7-6 09:48:27


(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))
)

Lee Mac 发表于 2022-7-6 10:06:42

使用一些几何图形怎么样。。。(类似于我在这里的帖子)。
 

(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))
   )
   )
)
)
 
测试功能:
 

(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)
)

kalai 发表于 2022-7-6 10:20:41

多亏了他们俩
它起作用了

Lee Mac 发表于 2022-7-6 10:35:34

在过去,我扩展了这个想法,并使用了grRead构造(不实用,但使用/写入很有趣):
 
 
以上代码随附,将在所有UCS/视图中工作,并且不依赖Visual LISP。
 
这是最终产品:
 
 

2圆切线。lsp
页: [1]
查看完整版本: 获取普通唐的坐标