展开全部
(princ "\n加载成功!启动快捷键 ccc")
;;;加载Active X功能
(vl-load-com)
;;;定义模型空间指针
(setq Mspace
(vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
;;;度->弧度函数
(defun DetoRad (numberOfDegrees)
(* pi (/ numberOfDegrees 180.0))
)
;;;主程序
(defun c:ccc (/ pt1 pt2 len deg deg1 deg2 key)
;;;获取基点,第二个角点(或边长,角度,设置默认值)
(setq pt1 (getpoint "\n点取或输入一个角点:"))
(initget "b B")
(setq pt2 (getpoint pt1 "\n点取或输入第二个角点或指定边长(b):")
)
(if (= pt2 "B")
(progn
(setq len (getdist "\n点取或输入边长(默认为1000):"))
(if (not len)
(setq len 1000)
)
)
)
(if len
(setq deg (getint "\n输入图形与水平轴的夹角(默认为0):"))
)
(if (not deg)
(setq deg 0)
)
(if (and pt2 (/= pt2 "B"))
(setq len (distance pt1 pt2)
deg (angle pt1 pt2)
)
)
;;;获取绘图方向,逆时针/顺时针
(initget "+ -")
(setq
key (getpoint
"\n选取方向参考点或输入“+”(逆时针),“-”(顺时针)(默认逆时针):"
)
)
(if (and key (and (/= key "+") (/= key "-")))
(progn
(setq deg1 (angle pt1 key )
deg2 (angle pt1 pt2)
deg1 (- deg1 deg2)
)
(cond ((<= deg1 pi) (setq key "+"))
((> deg1 pi) (setq key "-"))
)
)
)
(if (not key) (setq key "+"))
(draw pt1 len deg key)
(princ)
)
;;;画线子程序
(defun DRAW (pt1 len deg key / rr deg2 ptn num)
;;;计算半径,首次偏移距离
(setq rr (/ len (+ 8 (* (sqrt 3) 2)))
l1 (* (/ RR (sqrt 3)) 2)
pt pt1
num 5
)
(cond ((= key "+") (setq deg2 (+ deg (DetoRad 60))))
((= key "-") (setq deg2 (- deg (DetoRad 60))))
)
(command "PLINE")
;;;画三角形
(repeat 3
(progn
(command pt)
(setq pt (polar pt deg len))
(cond ((= key "+")(setq deg (+ deg (DetoRad 120)) ))
((= key "-")(setq deg (- deg (DetoRad 120)) ))
)
)
)
(command "c")
;;; 画圆形
(setq pt1 (polar (polar pt1 deg l1) deg2 l1))
(repeat 5
(progn
(setq pt pt1)
(repeat num
(progn
(vla-addcircle Mspace (vlax-3d-point pt) rr)
(setq pt (polar pt deg2 (* rr 2)))
)
)
(setq pt1 (polar pt1 deg (* rr 2))
num (1- num))
)
)
)
;;;加载Active X功能
(vl-load-com)
;;;定义模型空间指针
(setq Mspace
(vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
;;;度->弧度函数
(defun DetoRad (numberOfDegrees)
(* pi (/ numberOfDegrees 180.0))
)
;;;主程序
(defun c:ccc (/ pt1 pt2 len deg deg1 deg2 key)
;;;获取基点,第二个角点(或边长,角度,设置默认值)
(setq pt1 (getpoint "\n点取或输入一个角点:"))
(initget "b B")
(setq pt2 (getpoint pt1 "\n点取或输入第二个角点或指定边长(b):")
)
(if (= pt2 "B")
(progn
(setq len (getdist "\n点取或输入边长(默认为1000):"))
(if (not len)
(setq len 1000)
)
)
)
(if len
(setq deg (getint "\n输入图形与水平轴的夹角(默认为0):"))
)
(if (not deg)
(setq deg 0)
)
(if (and pt2 (/= pt2 "B"))
(setq len (distance pt1 pt2)
deg (angle pt1 pt2)
)
)
;;;获取绘图方向,逆时针/顺时针
(initget "+ -")
(setq
key (getpoint
"\n选取方向参考点或输入“+”(逆时针),“-”(顺时针)(默认逆时针):"
)
)
(if (and key (and (/= key "+") (/= key "-")))
(progn
(setq deg1 (angle pt1 key )
deg2 (angle pt1 pt2)
deg1 (- deg1 deg2)
)
(cond ((<= deg1 pi) (setq key "+"))
((> deg1 pi) (setq key "-"))
)
)
)
(if (not key) (setq key "+"))
(draw pt1 len deg key)
(princ)
)
;;;画线子程序
(defun DRAW (pt1 len deg key / rr deg2 ptn num)
;;;计算半径,首次偏移距离
(setq rr (/ len (+ 8 (* (sqrt 3) 2)))
l1 (* (/ RR (sqrt 3)) 2)
pt pt1
num 5
)
(cond ((= key "+") (setq deg2 (+ deg (DetoRad 60))))
((= key "-") (setq deg2 (- deg (DetoRad 60))))
)
(command "PLINE")
;;;画三角形
(repeat 3
(progn
(command pt)
(setq pt (polar pt deg len))
(cond ((= key "+")(setq deg (+ deg (DetoRad 120)) ))
((= key "-")(setq deg (- deg (DetoRad 120)) ))
)
)
)
(command "c")
;;; 画圆形
(setq pt1 (polar (polar pt1 deg l1) deg2 l1))
(repeat 5
(progn
(setq pt pt1)
(repeat num
(progn
(vla-addcircle Mspace (vlax-3d-point pt) rr)
(setq pt (polar pt deg2 (* rr 2)))
)
)
(setq pt1 (polar pt1 deg (* rr 2))
num (1- num))
)
)
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询