ReMark 发表于 2022-7-6 11:39:57

正如你所指出的,艾伦,如果OP能给我们一个关于圆的数量和配置的概念,这可能会很有帮助。他没有提到的另一件事是,如果所有的圆都是相同的大小,或者它们是否不同?

alanjt 发表于 2022-7-6 11:43:15

泄露有用信息?你一定是在开玩笑吧?

ReMark 发表于 2022-7-6 11:47:05

显然,我对人们的期望太高了。我得考虑降低我的标准。

dig 发表于 2022-7-6 11:50:36

我不能给你一张照片,因为我没有足够的帖子。
 
让我们看看:结果应该像alanjt第五篇文章中的结果,但圆圈内的线应该不可见。这就是全部。
 
非常感谢。

alanjt 发表于 2022-7-6 11:55:21

第五个帖子?我所做的就是用线连接一组圆(通过插入)。如果去掉这些线,你只会得到一堆随机的圆。

alanjt 发表于 2022-7-6 11:55:51

http://www.cadtutor.net/forum/showthread.php?t=46891&page=2
 
http://www.cadtutor.net/forum/showthread.php?t=42954
 

ReMark 发表于 2022-7-6 12:00:48

绕圈奔跑的人有福了,因为他们将被称为大轮子。

Lee Mac 发表于 2022-7-6 12:03:17

我做错了吗?
 
 
 

(defun c:cc ( / ent cen rad gr code data d ang tan iAng tmp )
;; © Lee Mac~23.05.10

(if
   (setq ent
   (SelectifFoo
       (lambda ( x ) (eq "CIRCLE" (cdr (assoc 0 (entget x)))))
       "\nSelect First Circle: "
   )
   )
   (progn
   (setq cen (trans (dxf 10 ent) 0 1) rad (dxf 40 ent))

   (princ "\nSelect Next Circle: ")
   (while
       (progn
         (setq gr (grread t 13 2) code (car gr) data (cadr gr))

         (redraw)

         (cond
         (
             (and (= 5 code) (listp data))

             (setq d (distance cen data) ang (angle cen data))

             (if (< rad d)
               (progn
               (setq tan(sqrt (- (* d d) (* rad rad)))
                     iAng (atan tan rad))

               (grvecs
                   (cons -3
                     (list
                     (polar cen (+ ang iAng) rad) data
                     (polar cen (- ang iAng) rad) data
                     )
                   )
               )
               )
             )
            t
         )
         (
             (and (= 3 code) (listp data))

             (if (and (setq tmp (car (nentselp data)))
                      (eq "CIRCLE" (cdr (assoc 0 (entget tmp))))
                      (CircleTangents ent tmp))

               (setq ent tmp cen (trans (dxf 10 tmp) 0 1) rad (dxf 40 tmp))
             )
            t
         )
         )
       )
   )
   (redraw)
   )
)
(princ)
)


(defun SelectifFoo ( foo str / sel ent )
;; © Lee Mac~23.05.10
(while
   (progn
   (setq sel (entsel str))
   
   (cond
       (
         (vl-consp sel)

         (if (not (foo (setq ent (car sel))))
         (princ "\n** Invalid Object Selected **")
         )
       )
   )
   )
)
ent
)

(defun Line ( p1 p2 )
(entmakex
   (list
   (cons 0 "LINE")
   (cons 10 p1)
   (cons 11 p2)
   )
)
)

(defun dxf ( code e )
(cdr (assoc code (entget e)))
)

(defun CircleTangents ( cir1 cir2 / c1 c2 r1 r2 d delta ang tan iAng )
;; © Lee Mac~23.05.10

(setq c1 (dxf 10 cir1) c2 (dxf 10 cir2)
       r1 (dxf 40 cir1) r2 (dxf 40 cir2))

(setq d(distance c1 c2) delta (- r1 r2) ang (angle c1 c2))

(if (< (abs delta) d)
   (progn
   (setq tan(sqrt (- (* d d) (* delta delta)))
         iAng (atan tan delta))

   (Line (polar c1 (+ ang iAng) r1)
         (polar c2 (+ ang iAng) r2))

   (Line (polar c1 (- ang iAng) r1)
         (polar c2 (- ang iAng) r2))
   )
)
)

alanjt 发表于 2022-7-6 12:06:39

哈哈,做得很好。本周末GrRead的两个出色应用。
http://www.cadtutor.net/forum/showpost.php?p=328770&postcount=31

Lee Mac 发表于 2022-7-6 12:09:52

谢谢Alan
页: 1 [2]
查看完整版本: 连接圆