编写一个AutoLISP程序,画出一个边长为A的正方形,以及该正方形的内切圆,正方形的底边与正X轴的夹角为ANG

1个回答

  • (defun c:zfx(/ A ANG p1 p2 p3 p4 p5 os cmd)

    (SETQ CMD (GETVAR "cmdecho"))

    (SETVAR "cmdecho" 0)

    (setq os (getvar "osmode"))

    (setq A (getreal"n:输入边长"))

    (setq ANG (getreal"n:输入角度"))

    (setq p1 (getpoint"n:指定起点"))

    (setvar "osmode" 0)

    (setq p2 (polar p1 (* pi (/ ANG 180)) A))

    (setq p3 (polar p2 (* pi (+ 0.5 (/ ANG 180))) A))

    (setq p4 (polar p1 (* pi (+ 0.5 (/ ANG 180))) A))

    (command "pline" p1 p2 p3 p4 "c")

    (SETQ p5 (polar p1 (+ (* pi (/ ANG 180)) (* 0.25 pi)) (* A (sin (/ pi 4)))))

    (command "circle" p5 (* 0.5 A))

    (setvar "osmode" os)

    (SETVAR "cmdecho" CMD)

    (PRINC)

    )