明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2504|回复: 11

感觉比CAD自带的切切切绘圆命令都棒100倍的程序,包你检到宝!

    [复制链接]
发表于 2012-4-22 08:44 | 显示全部楼层 |阅读模式
; =======================================================
; AUTOLISP 实用程序
; 2012 年 01月
; 作 者:王颖
;
; 本程式仅供非商业的使用,严格禁止未经作者同意的贩售或租借。
; 并且本版权宣告不可删除。
; =======================================================
;;;切切切绘圆
(defun C:TTT (/ os ap e1 en1 ena pa vs Ls p1 p2 p3 p4
e2 en2 enb pb e3 en3 pc e4 B e5 nu)
(setq m:err *error* *error* *merr*)
(setvar "cmdecho" 0)
(command "UNDO" "G")
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq ap (getvar "aperture"))
(setvar "aperture" 10)
(while (= e1 nil)
(setq e1 (entsel "\n选取第一个相切图元:"))
) ;while
(setq en1 (cdr (assoc '0 (entget (car e1)))))
(while (= en1 "SPLINE")
(princ "\n不可选取样条曲线!")
(setq e1 (entsel "\n选取第一个相切图元:"))
(while (not e1)
(setq e1 (entsel "\n选取第一个相切图元:"))
) ;while
(setq en1 (cdr (assoc '0 (entget (car e1)))))
) ;;while
(setq ena (car e1))
(redraw ena 3)
(setq pa (cadr e1))
(setq pa (osnap pa "nearest"))
(setq vs (getvar "viewsize"))
(setq Ls (/ vs 32))
(setq p1 (polar pa (* pi 0.25) Ls))
(setq p2 (polar pa (* pi 1.25) Ls))
(setq p3 (polar pa (* pi 0.75) Ls))
(setq p4 (polar pa (* pi 1.75) Ls))
(grvecs (list 2 p1 p2 2 p3 p4))
(while (= e2 nil)
(setq e2 (entsel "\n选取第二个相切图元:"))
) ;while
(setq en2 (cdr (assoc '0 (entget (car e2)))))
(while (= en2 "SPLINE")
(princ "\n不可选取样条曲线!")
(setq e2 (entsel "\n选取第二个相切图元:"))
(while (not e2)
(setq e2 (entsel "\n选取第二个相切图元:"))
) ;while
(setq en2 (cdr (assoc '0 (entget (car e2)))))
) ;;while
(setq enb (car e2))
(redraw enb 3)
(setq pb (cadr e2))
(setq pb (osnap pb "nearest"))
(setq p1 (polar pb (* pi 0.25) Ls))
(setq p2 (polar pb (* pi 1.25) Ls))
(setq p3 (polar pb (* pi 0.75) Ls))
(setq p4 (polar pb (* pi 1.75) Ls))
(grvecs (list 2 p1 p2 2 p3 p4))
(while (= e3 nil)
(setq e3 (entsel "\n选取第三个相切图元:"))
) ;while
(setq en3 (cdr (assoc '0 (entget (car e3)))))
(while (= en3 "SPLINE")
(princ "\n不可选取样条曲线!")
(setq e3 (entsel "\n选取第三个相切图元:"))
(while (not e3)
(setq e3 (entsel "\n选取第三个相切图元:"))
) ;while
(setq en3 (cdr (assoc '0 (entget (car e3)))))
) ;;while
(setq pc (cadr e3))
(setq pc (osnap pc "nearest"))
(redraw)
(setq e4 (entlast))
(if (= e4 nil)(setq e4 e3))
(setq B (ssadd))
(ssadd e4 B)
(redraw ena 4)
(redraw enb 4)
(command "circle" "3p" "tan" pa "tan" pb "tan" pc)
(setq e5 (entlast))
(if (= e5 nil)(setq e5 e3))
(ssadd e5 B)
(setq nu (sslength B))
(if (> nu 1)
(princ "\n三切圆绘制完成!")
(princ "\n无法生成三切圆!"))
(setvar "aperture" ap)
(setvar "osmode" os)
(command "UNDO" "E")
(princ))

点评

又是一个套套函数  发表于 2012-4-22 14:24

评分

参与人数 1明经币 +1 金钱 +12 收起 理由
Gu_xl + 1 + 12 赞一个!

查看全部评分

发表于 2012-4-22 09:26 | 显示全部楼层
抢占沙发,支持一下,
发表于 2012-4-22 09:33 | 显示全部楼层
坐在板凳上,顶!
发表于 2012-4-22 10:21 | 显示全部楼层
经测试,实现不了你说的功能
发表于 2012-4-22 13:44 | 显示全部楼层
这个工具真实用.
发表于 2012-4-22 15:13 | 显示全部楼层
本帖最后由 Gu_xl 于 2012-4-22 15:14 编辑

其实三切画圆circle命令直接就可以画!
不考虑容错情况,一句代码就OK!
(command "circle" "3p" "tan" (getpoint "\n第一切点") "tan" (getpoint "\n第二切点") "tan" (getpoint "\n第三切点"))
发表于 2012-4-22 15:49 来自手机 | 显示全部楼层
不支持样条曲线,谈不上棒100倍。。。。
必须进行优化!!!
发表于 2012-4-22 16:59 | 显示全部楼层
试用,看看怎么样,谢楼主了
发表于 2012-4-23 08:04 | 显示全部楼层
Gu_xl 版说的对,感觉不需要那么复杂,
即使是自带的程序(本身就有三切点定圆的功能)也很好用啊,请问楼主这个比自带的好在哪里

"其实三切画圆circle命令直接就可以画!不考虑容错情况,一句代码就OK!"
 楼主| 发表于 2012-4-23 08:12 | 显示全部楼层
选没选到相切图元,一目了然
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-10 11:34 , Processed in 0.165294 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表