乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 91|回复: 19

[编程交流] 自定义旋转/缩放

[复制链接]

2

主题

12

帖子

11

银币

初来乍到

Rank: 1

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

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 17:27:01 | 显示全部楼层
试试这个:
  1. (defun c:test ()
  2. ;;  CAB version 1.0
  3. ;;  Calling routine to pass a center point & offset distance
  4. ;;  Routine will allow user to streatch outer circle
  5. ;;  Note if offset distance is a negative number the offset circle
  6. ;;  will be on the outside
  7. ;;
  8. ;;  Returns the distance to the 2nd pick point
  9. (defun ghostCircle (p1 r2 / *error* r1 c1 c2 el1 el2 gr rMin)
  10.    (defun *error* (msg)
  11.      (if (not
  12.            (member msg '("Console break" "Function cancelled" "quit / exit abort" "" nil))
  13.          )
  14.        (princ (strcat "\nError: " msg))
  15.      )
  16.      (and c1 (entdel c1))
  17.      (and c2 (entdel c2))
  18.      (princ)
  19.    )     ; end error function
  20.    
  21.    (setq rMin 0.001)
  22.    (setq c1
  23.           (entmakex (list (cons 0 "CIRCLE")
  24.                           (cons 6 "BYLAYER")
  25.                           (cons 8 "0")
  26.                           (cons 10 p1)
  27.                           (cons 39 0.0)
  28.                           (cons 40 rMin) ; radius
  29.                           (cons 62 256)
  30.                           (cons 210 (list 0.0 0.0 1.0))
  31.                     )
  32.           )
  33.    )
  34.    (setq c2
  35.           (entmakex (list (cons 0 "CIRCLE")
  36.                           (cons 6 "BYLAYER")
  37.                           (cons 8 "0")
  38.                           (cons 10 p1)
  39.                           (cons 39 0.0)
  40.                           (cons 40 rMin) ; radius
  41.                           (cons 62 256)
  42.                           (cons 210 (list 0.0 0.0 1.0))
  43.                     )
  44.           )
  45.    )
  46.    (setq el1 (entget c1)
  47.          el2 (entget c2)
  48.    )
  49.    (while (and (setq gr (grread 5)) (= (car gr) 5))
  50.      (cond
  51.        ((> (setq r1 (distance p1 (cadr gr))) rMin)
  52.         (entmod (subst (cons 40 (distance p1 (cadr gr))) (assoc 40 el1) el1))
  53.         (entupd (cdr (assoc -1 el1)))
  54.         (cond
  55.           ((> r1 (+ rMin r2))
  56.            (entmod (subst (cons 40 (- r1 r2)) (assoc 40 el2) el2))
  57.            (entupd (cdr (assoc -1 el2)))
  58.           )
  59.           (t ; minimize the inner circle
  60.            (entmod (subst (cons 40 rMin) (assoc 40 el2) el2))
  61.            (entupd (cdr (assoc -1 el2)))
  62.           )
  63.         )
  64.        )
  65.        (t ; minimize the outer circle
  66.         (entmod (subst (cons 40 rMin) (assoc 40 el1) el1))
  67.         (entupd (cdr (assoc -1 el1)))
  68.        )
  69.      )
  70.    )
  71.    (entdel c1)
  72.    (entdel c2)
  73.    r1
  74. )
  75. (setq pc (getpoint "\nPick center point."))
  76. (princ "\n Select new radius  ")
  77. (setq rad (ghostcircle pc 850.0)) ; center point & offset distance
  78. (princ rad)
  79. (princ)
  80. )
回复

使用道具 举报

2

主题

12

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 17:29:19 | 显示全部楼层
 
 
好的,这是可行的,但我想在外圆上选择一个点,而不是中心。。并且能够围绕那个点旋转。
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 17:32:24 | 显示全部楼层
抱歉,我在代码中留下了最后一个测试偏移量。
更改此行
(setq rad(ghostcircle pc-10.0))
到这个
(setq rad(ghostcircle pc 850.0))
这将使您的外圈偏移850个单位。
 
 
也许我不明白你在追求什么。
你想在内圈上选取一个切点,然后悄悄地转到
中心点?
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 17:36:23 | 显示全部楼层
我刚把代码改为850偏移量,所以再复制一次。
回复

使用道具 举报

2

主题

12

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 17:39:39 | 显示全部楼层
 
我想在外圆上选取一个切点,然后拉伸到另一个切点。并且能够围绕第一个点旋转。
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 17:41:39 | 显示全部楼层
好啊
第二个点与圆半径的关系是什么?
一对一?
回复

使用道具 举报

2

主题

12

帖子

11

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 17:44:51 | 显示全部楼层
 
嗯。。我不知道。试试我在第一篇帖子里说的话。圆形,2p,选择一个点,看看当你移动光标时会发生什么。。圆跟踪光标,使圆变大或围绕第一个点旋转。然后可以选择第二个点。我也想做同样的事情,但是在外圆内可以看到另一个圆。这有点难以解释。。
回复

使用道具 举报

15

主题

102

帖子

106

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 17:48:24 | 显示全部楼层
 
你需要提供更多的信息,或者某种视觉效果。不要说你做不到,因为有了CAD,你可以做/展示一切。
回复

使用道具 举报

CAB

29

主题

781

帖子

430

银币

中流砥柱

Rank: 25

铜币
526
发表于 2022-7-6 17:49:37 | 显示全部楼层
 
哦,我现在明白了。我从不使用2p选项。
在该方法中,第二个拾取点是圆的直径和对边。
午饭后我会修改代码。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 16:47 , Processed in 0.691830 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表