乐筑天下

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

[编程交流] 获取普通唐的坐标

[复制链接]

26

主题

67

帖子

41

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
130
发表于 2022-7-6 09:24:47 | 显示全部楼层 |阅读模式
我必须得到两个圆的公共(外)切线的坐标。
  1. c1= '(0 0)
  2. c2='(0 15)
  3. r1 =12.5
  4. r2=5
  5. ;c1 and c2 centers
  6. ;r1 and r2 radius

 
请帮帮我。
回复

使用道具 举报

91

主题

428

帖子

326

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
474
发表于 2022-7-6 09:48:27 | 显示全部楼层
  1. (defun C:Go ()
  2.   (vl-load-com)
  3.   (setvar 'Osmode 512)
  4.   (while (not (setq 1st (entsel "Select first circle: "))))
  5.   (while (not (setq 2nd (entsel "Select second circle: "))))
  6.   (setq 1st (osnap (last 1st) "_Nea"))
  7.   (setq 2nd (osnap (last 2nd) "_Nea"))
  8.   (command "_.LINE" "_Tan" 1st "_Tan" 2nd "")
  9.   (setq line (entget (entlast)))
  10.   (princ
  11.      (strcat
  12.         "\nCoords:\t\t"
  13.         (vl-princ-to-string (cdr (assoc 10 line)))
  14.         "\t"
  15.         (vl-princ-to-string (cdr (assoc 11 line)))
  16.      )
  17.   )
  18.   (entdel (entlast))
  19. )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:06:42 | 显示全部楼层
使用一些几何图形怎么样。。。(类似于我在这里的帖子)。
 
  1. (defun LM:2CircleTangents ( c1 r1 c2 r2 / d1 d2 tan ang )
  2. (if (< (abs (setq d1 (- r1 r2))) (setq d2 (distance c1 c2)))
  3.    (progn
  4.      (setq tan (atan (sqrt (- (* d2 d2) (* d1 d1))) d1)
  5.            ang (angle c1 c2)
  6.      )
  7.      (list
  8.        (list (polar c1 (+ ang tan) r1) (polar c1 (- ang tan) r1))
  9.        (list (polar c2 (+ ang tan) r2) (polar c2 (- ang tan) r2))
  10.      )
  11.    )
  12. )
  13. )

 
测试功能:
 
  1. (defun c:test ( / cir1 cir2 )
  2. (if
  3.    (and
  4.      (setq cir1 (car (entsel "\nSelect First Circle: ")))
  5.      (eq "CIRCLE" (cdr (assoc 0 (setq cir1 (entget cir1)))))
  6.      (setq cir2 (car (entsel "\nSelect Second Circle: ")))
  7.      (eq "CIRCLE" (cdr (assoc 0 (setq cir2 (entget cir2)))))
  8.    )
  9.    (apply 'mapcar
  10.      (cons '(lambda ( a b ) (entmakex (list (cons 0 "LINE") (cons 10 a) (cons 11 b))))
  11.        (LM:2CircleTangents
  12.          (cdr (assoc 10 cir1)) (cdr (assoc 40 cir1))
  13.          (cdr (assoc 10 cir2)) (cdr (assoc 40 cir2))
  14.        )
  15.      )
  16.    )
  17. )
  18. (princ)
  19. )
回复

使用道具 举报

26

主题

67

帖子

41

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
130
发表于 2022-7-6 10:20:41 | 显示全部楼层
多亏了他们俩
它起作用了
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:35:34 | 显示全部楼层
在过去,我扩展了这个想法,并使用了grRead构造(不实用,但使用/写入很有趣):
 
 
以上代码随附,将在所有UCS/视图中工作,并且不依赖Visual LISP。
 
这是最终产品:
 
 

2圆切线。lsp
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 02:50 , Processed in 0.535328 second(s), 62 queries .

© 2020-2025 乐筑天下

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