绘制隧道轮廓,东拼西凑,望大神帮忙优化
(defun c:ac ()
(entmake
(list '(0 . "ARC")
(cons 10 (setq cen (getpoint "\n指定圆心")))
(cons 40 (getdist cen "\n指定半径"))
(cons 50 (setq sang (angle cen (getpoint cen "\n指定起点"))))
(cons 51 (+ sang (* pi (/ (getreal "\n指定角度(°)") 180.0))))
)
)
)
(defun c:ac1()
(setq a (getpoint "\n请指点圆弧的起点:"))
(setq b (getpoint "\n请指定圆弧的端点:"))
(setq c (getreal"\n请输入你想要的半径:"))
(command "arc" a "E" b "R" c "")
(princ
)
)
:hug:强大,学习了:lol (defun c:ac ()
(setq start-point (getpoint "\n指定圆弧的起点 <退出>: "))
(while start-point
(setq dir-point (getpoint start-point "\n指定半径方向: "))
(setq rad (getdist start-point "\n指定半径长度: "))
(setq cen (polar start-point (angle start-point dir-point) rad)) ; 计算圆心位置
(setq sang (angle cen start-point)) ; 起点角度
(setq deg (getint "\n请输入角度的度数部分: "))
(setq min (getint "\n请输入角度的分数部分: "))
(setq sec (getint "\n请输入角度的秒数部分: "))
(setq total-deg (+ deg (/ min 60.0) (/ sec 3600.0))) ; 将度分秒转换为十进制度数
(setq eang (+ sang (* pi (/ total-deg 180.0)))) ; 计算终点角度
(entmake
(list '(0 . "ARC")
(cons 10 cen)
(cons 40 rad)
(cons 50 sang)
(cons 51 eang)
)
)
(princ "\n继续绘制圆弧...按任意键继续,按 'Esc' 键退出")
(setq start-point (getpoint "\n指定下一个圆弧的起点 <按 'Esc' 退出>: "))
)
(princ "\n圆弧绘制完成。")
(princ)
)
(defun c:ac1()
(setq a (getpoint "\n请指点圆弧的起点:"))
(setq b (getpoint "\n请指定圆弧的端点:"))
(setq c (getreal"\n请输入你想要的半径:"))
(command "arc" a "E" b "R" c "")
(princ
)
)
(princ "\n加载完成,可以使用 c:ac 和 c:ac1 命令。")
(princ) (defun c:ac ()
(setq start-point (getpoint "\n指定圆弧的起点 <退出>: "))
(while start-point
(setq dir-point (getpoint start-point "\n指定半径方向: "))
(setq rad (getdist start-point "\n指定半径长度: "))
(setq cen (polar start-point (angle start-point dir-point) rad)) ; 计算圆心位置
(setq sang (angle cen start-point)) ; 起点角度
(setq eang (+ sang (* pi (/ (getreal "\n指定角度(°): ") 180.0)))) ; 计算终点角度
(entmake
(list '(0 . "ARC")
(cons 10 cen)
(cons 40 rad)
(cons 50 sang)
(cons 51 eang)
)
)
(princ "\n继续绘制圆弧...按任意键继续,按 'Esc' 键退出")
(setq start-point (getpoint "\n指定下一个圆弧的起点 <按 'Esc' 退出>: "))
)
(princ "\n圆弧绘制完成。")
(princ)
)
(defun c:ac1()
(setq a (getpoint "\n请指点圆弧的起点:"))
(setq b (getpoint "\n请指定圆弧的端点:"))
(setq c (getreal"\n请输入你想要的半径:"))
(command "arc" a "E" b "R" c "")
(princ
)
)
(princ "\n加载完成,可以使用 c:ac 和 c:ac1 命令。")
(princ) 程序简洁易懂,有实用性价值。你想要的半径加个默认值 更方便些! 圆心、半径、起始角度和终止角度画弧
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=191999&fromuid=7316343
(出处: 明经CAD社区)
尽量少输入参数,人为给它固定下来。效率更高。 优化以后,实际应用更方便 角度输入更方便 (defun c:tt ()
"底宽和半径画圆弧"
(defun udist (bit kwd msg def bpt / inp)
(if def
(setq msg(strcat"\n"msg"<"(rtos def)">: ")
bit(* 2(fix(/ bit 2)))
)
(setq msg(strcat"\n"msg": "))
)
(initget bit kwd)
(setq inp(if bpt(getdist msg bpt)(getdist msg)))
(if inp inp def)
)
(or dd (setq dd 20.))
(or rr (setq rr 15.))
(setq dd (Udist 7 "" "底宽<输入或鼠标直接量取>" dd nil))
(setq rr (Udist 7 "" "半径<输入或鼠标直接量取>" rr nil))
(if (and (setq d1 (* dd 0.5))
(< d1 rr)
(setq p0 (getpoint "\n底部中心基点<退出>: "))
)
(setq p1 (polarp0 pi d1)
p2 (polarp0 0 d1)
r1 (sqrt (- (* rr rr) (* d1 d1)))
p3 (polarp0 (* pi 0.5) (+ r1 rr))
s1 (command "arc" "non" p2 "non"p3 "non"p1)
)
)
(princ)
)
页:
[1]
2