如何用lisp语言画椭圆
发布网友
发布时间:2022-04-26 01:02
我来回答
共2个回答
热心网友
时间:2022-06-19 02:05
CAD中画圆弧有几种方法
只介绍一种(圆心、起点、端点)。
要画圆弧就需要以上3个要素(圆心、起点、端点)有明确数值,这3个要素可以在程序中设定,也可以定义变量在操作是一一再输入变量数值(输入数值方法与CAD内部命令相同)。
最后用COMMAND执行画弧命令。
代码:
(DEFUN
c:MARC(/
p0,p1,p2)
;;--MARC为本程序调用命令,也可设成其它字母,前提是不要与CAD内部命令冲突
(setq
p0
(getpoint"o点:"))
;;------------拾取原点
(setq
p1(getpoint"起点:"))
;;------------拾取起点
(setq
p2
(getpoint"端点:"))
;;------------拾取端点
(command
"osmode"
16575)
;;关掉捕捉以免在绘图时受到影响
(command
"_arc"
"c"
p0
p1
p2)
(command
"osmode"
191)
;;开捕捉
)
其它画法相似
热心网友
时间:2022-06-19 02:06
;一个比较传统的求法
(defun c:test()
(if (setq ent (car (entsel "\n请选择圆弧:")))
(if (= (cdr (assoc 0 (setq db (entget ent)))) "ARC")
(progn
(setq pc (cdr (assoc 10 db)) ;圆心
r (cdr (assoc 40 db)) ;半径
a0 (cdr (assoc 50 db))
a1 (cdr (assoc 51 db))
ps (polar pc a0 r);起点
pe (polar pc a1 r);止点
pd (mapcar '* '(0.5 0.5) (mapcar '+ ps pe))
pm (polar pc (angle pc pd) r);中点
an (- a1 a0);圆心角
)
(if (< an 0) (setq an (+ an (* 2.0 pi))))
(princ (strcat "\n圆心=" (rtos (car pc) 2 3) "," (rtos (cadr pc) 2 3)))
(princ (strcat "\n起点=" (rtos (car ps) 2 3) "," (rtos (cadr ps) 2 3)))
(princ (strcat "\n止点=" (rtos (car pe) 2 3) "," (rtos (cadr pe) 2 3)))
(princ (strcat "\n中点=" (rtos (car pm) 2 3) "," (rtos (cadr pm) 2 3)))
(princ (strcat "\n圆心角=" (angtos an 1 6) ))
)
(alert "所选取的不是圆弧!")
)
)
)