SstennizZ 发表于 2022-7-6 17:20:38

自定义旋转/缩放

我想做以下工作:
当我用circle命令绘制一个圆时,我可以选择2p。如果单击第一个点并移动光标,将出现一个圆形,该圆形根据圆形的移动进行缩放和旋转。(如果你不懂我的意思,试试看)
我希望能够做到这一点,但是有一个圆,其中有另一个圆,偏移量为850。所以我希望能够有一个固定点,然后看到两个圆随着光标移动。内圈必须与外圈保持850的距离,固定点必须位于外圈。我希望我能举个例子,但这是不可能的。。
 
有人能帮我吗?

CAB 发表于 2022-7-6 17:27:01

试试这个:
(defun c:test ()

;;CAB version 1.0
;;Calling routine to pass a center point & offset distance
;;Routine will allow user to streatch outer circle
;;Note if offset distance is a negative number the offset circle
;;will be on the outside
;;
;;Returns the distance to the 2nd pick point
(defun ghostCircle (p1 r2 / *error* r1 c1 c2 el1 el2 gr rMin)
   (defun *error* (msg)
   (if (not
         (member msg '("Console break" "Function cancelled" "quit / exit abort" "" nil))
         )
       (princ (strcat "\nError: " msg))
   )
   (and c1 (entdel c1))
   (and c2 (entdel c2))
   (princ)
   )   ; end error function

   
   (setq rMin 0.001)
   (setq c1
          (entmakex (list (cons 0 "CIRCLE")
                        (cons 6 "BYLAYER")
                        (cons 8 "0")
                        (cons 10 p1)
                        (cons 39 0.0)
                        (cons 40 rMin) ; radius
                        (cons 62 256)
                        (cons 210 (list 0.0 0.0 1.0))
                  )
          )
   )
   (setq c2
          (entmakex (list (cons 0 "CIRCLE")
                        (cons 6 "BYLAYER")
                        (cons 8 "0")
                        (cons 10 p1)
                        (cons 39 0.0)
                        (cons 40 rMin) ; radius
                        (cons 62 256)
                        (cons 210 (list 0.0 0.0 1.0))
                  )
          )
   )
   (setq el1 (entget c1)
         el2 (entget c2)
   )
   (while (and (setq gr (grread 5)) (= (car gr) 5))
   (cond
       ((> (setq r1 (distance p1 (cadr gr))) rMin)
      (entmod (subst (cons 40 (distance p1 (cadr gr))) (assoc 40 el1) el1))
      (entupd (cdr (assoc -1 el1)))
      (cond
          ((> r1 (+ rMin r2))
         (entmod (subst (cons 40 (- r1 r2)) (assoc 40 el2) el2))
         (entupd (cdr (assoc -1 el2)))
          )
          (t ; minimize the inner circle
         (entmod (subst (cons 40 rMin) (assoc 40 el2) el2))
         (entupd (cdr (assoc -1 el2)))
          )
      )
       )
       (t ; minimize the outer circle
      (entmod (subst (cons 40 rMin) (assoc 40 el1) el1))
      (entupd (cdr (assoc -1 el1)))
       )
   )
   )
   (entdel c1)
   (entdel c2)
   r1
)


(setq pc (getpoint "\nPick center point."))
(princ "\n Select new radius")
(setq rad (ghostcircle pc 850.0)) ; center point & offset distance
(princ rad)
(princ)
)

SstennizZ 发表于 2022-7-6 17:29:19

 
 
好的,这是可行的,但我想在外圆上选择一个点,而不是中心。。并且能够围绕那个点旋转。

CAB 发表于 2022-7-6 17:32:24

抱歉,我在代码中留下了最后一个测试偏移量。
更改此行
(setq rad(ghostcircle pc-10.0))
到这个
(setq rad(ghostcircle pc 850.0))
这将使您的外圈偏移850个单位。
 
 
也许我不明白你在追求什么。
你想在内圈上选取一个切点,然后悄悄地转到
中心点?

CAB 发表于 2022-7-6 17:36:23

我刚把代码改为850偏移量,所以再复制一次。

SstennizZ 发表于 2022-7-6 17:39:39

 
我想在外圆上选取一个切点,然后拉伸到另一个切点。并且能够围绕第一个点旋转。

CAB 发表于 2022-7-6 17:41:39

好啊
第二个点与圆半径的关系是什么?
一对一?

SstennizZ 发表于 2022-7-6 17:44:51

 
嗯。。我不知道。试试我在第一篇帖子里说的话。圆形,2p,选择一个点,看看当你移动光标时会发生什么。。圆跟踪光标,使圆变大或围绕第一个点旋转。然后可以选择第二个点。我也想做同样的事情,但是在外圆内可以看到另一个圆。这有点难以解释。。

neekcotrack 发表于 2022-7-6 17:48:24

 
你需要提供更多的信息,或者某种视觉效果。不要说你做不到,因为有了CAD,你可以做/展示一切。

CAB 发表于 2022-7-6 17:49:37

 
哦,我现在明白了。我从不使用2p选项。
在该方法中,第二个拾取点是圆的直径和对边。
午饭后我会修改代码。
页: [1] 2
查看完整版本: 自定义旋转/缩放