用CAD里的LISP画图,题目如图片,编写一程序,可在任意位置任意方向绘制指定大小的指北针。
3个回答
2016-05-06 · 知道合伙人软件行家
关注
展开全部
写了一个,图如下:
autolisp代码如下:
(defun c:tes ( / &ang1 &ang2 &dis1 &ent1 &kw1 &p1 &p2 &p3 &p4 &p5 &pt1 &pt2 &r1 &r2 x)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(if (and (setq &p1 (getpoint "\n请指定圆心"))
(setq &r1 (getdist &p1 "\n请输入圆半径"))
)
(progn
(setq &r2 (* &r1 2))
(entmake (list '(0 . "CIRCLE") (cons 10 &p1) (cons 40 &r1)))
(setq &ent1 (entlast) &kw1 (ssadd) &kw1 (ssadd &ent1 &kw1))
(setq &p5 (cadr (grread t)))
(if (= (distance &p1 &p5) 0) (setq &ang1 0) (setq &ang1 (angle &p1 &p5)) )
(setq &p2 (polar &p1 &ang1 &r2) &p3 (polar &p1 (+ &ang1 (* pi 0.8)) &r2) &p4 (polar &p1 (- &ang1 (* pi 0.8)) &r2))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 3) '(70 . 1) (cons 10 &p1) (cons 10 &p2) (cons 10 &p3)))
(setq &ang2 (angle &p2 &p4) &pt1 (polar &p2 &ang2 &r2) &dis1 (distance &p1 &pt1) &pt1 (mapcar '(lambda (x) (* x 0.5)) (mapcar '+ &p1 &pt1)))
(setq &pt2 (polar &p4 &ang2 (* &r2 -1)) &pt2 (mapcar '(lambda (x) (* x 0.5)) (mapcar '+ &p1 &pt2)))
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 4) (cons 10 &p2) '(40 . 0.0) (cons 41 &dis1) (cons 10 &pt1)(cons 10 &pt2) (cons 40 &dis1) '(41 . 0.0) (cons 10 &p4)))
(setq &p4 (polar &p1 &ang1 (* &r2 -1)) &ang2 (+ &ang1 (* pi 0.5)))
(entmake (list '(0 . "TEXT") (cons 1 "N") (cons 10 &p4) (cons 40 (* &r1 0.8)) '(41 . 0.6) (cons 50 &ang2) '(72 . 4) (cons 11 &p4)))
(while (setq &ent1 (entnext &ent1)) (setq &kw1 (ssadd &ent1 &kw1)) )
(command "ROTATE" &kw1 "" &p1 "R" &p1 &p2)
)
)
(princ)
)
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询