AutoCAD LISP多边形边为直径绘制圆,代码如下。
(defun :test()
(setvar "cmdecho" 0)
(setq pt1 (getpoint "\n起点:"))
(command "pline" pt1)
(setq pt2 (getpoint pt1 "\n第二点:"))
(command pt2)
(setq pt3 (getpoint pt2 "\n第三点:"))
(command pt3)
(setq pt4 (getpoint pt3 "\n第四点:"))
(command pt4)
(setq pt5 (getpoint pt4 "\n第五点:"))
(command pt5 "c")
(setq dist1-2 (distance pt1 pt2))
(setq dist2-3 (distance pt2 pt3))
(setq dist3-4 (distance pt3 pt3))
(setq dist4-5 (distance pt4 pt5))
(setq dist5-1 (distance pt5 pt1))
(setq cc '())
(setq cc (cons (list dist1-2 pt1 pt2) cc))
(setq cc (cons (list dist2-3 pt2 pt3) cc))
(setq cc (cons (list dist3-4 pt3 pt4) cc))
(setq cc (cons (list dist4-5 pt4 pt5) cc))
(setq cc (cons (list dist5-1 pt5 pt1) cc))
(setq max_dd (max dist1-2 dist2-3 dist3-4 dist4-5 dist5-1))
(setq min_dd (min dist1-2 dist2-3 dist3-4 dist4-5 dist5-1))
(setq max_pt (assoc max_dd cc))
(setq max_pt1 (cadr max_pt))
(setq max_pt2 (caddr max_pt))
(setq max_ptm (polar max_pt1 (angle max_pt1 max_pt2) (/ max_dd 2)))
(setq min_pt (assoc min_dd cc))
(setq min_pt1 (cadr min_pt))
(setq min_pt2 (caddr min_pt))
(command "arc" max_pt1 "e" max_ptm "a" 180)
(command "arc" max_ptm "e" max_pt2 "a" 180)
(command "arc" min_pt1 "e" min_pt2 "a" 180)
(prin1)
)
代码完。
按照顺时针和逆时针选取点,绘制的圆分别在多边形内部和外部,应该能让所绘制的圆全部在外部。