autolisp教程 请高手用AutoLISP编写4个小程序:

1个回答

  • (一)

    (defun c:tuxing1 ()

    (setq Rd (getdist "n R=:"))

    (setq Rx (getdist "n r=:"))

    (setq p0 (getPoint "n Enter Center of Circle"))

    (setq p1 (list(car p0) (+ (+ (cadr p0) Rd) 5)))

    (setq p2 (list(- (- (car p0) Rd) 5) (cadr p0)))

    (setq p3 (list(car p0) (- (- (cadr p0) Rd) 5)))

    (setq p4 (list(+ (+ (car p0) Rd) 5) (cadr p0)))

    (Command "line" p1 p3"")

    (Command "line" p2 p4"")

    (Command "circle" p0 Rd)

    (Command "circle" p0 RX)

    )

    (二)

    (defun c:tuxing2 ()

    (setq Rd (getdist "n R=:"))

    (setq Rx (getdist "n r=:"))

    (setq p0 (getPoint "n Enter Center of Circle"))

    (setq a1 (list(+ (car p0) (* (cos (/ pi 4)) Rx)) (+ (cadr p0) (* (cos (/ pi 4)) Rx))))

    (setq a2 (list(- (car p0) (* (cos (/ pi 4)) Rx)) (cadr a1)))

    (setq a3 (list(car a2) (- (cadr p0) (* (cos (/ pi 4)) Rx))))

    (setq a4 (list(car a1) (cadr a3)))

    (setq b1 (list(+ (car p0) (* (cos (/ pi 4)) Rd)) (+ (cadr p0) (* (cos (/ pi 4)) Rd))))

    (setq b2 (list(- (car p0) (* (cos (/ pi 4)) Rd)) (cadr b1)))

    (setq b3 (list(car b2) (- (cadr p0) (* (cos (/ pi 4)) Rd))))

    (setq b4 (list(car b1) (cadr b3)))

    (Command "line" a1 a2 a3 a4 a1"")

    (Command "line" b1 b2 b3 b4 b1"")

    (Command "circle" p0 Rd)

    (Command "circle" p0 RX)

    )

    (三)

    (defun c:tuxing3 ()

    (setq r (getdist "n r=:"))

    (setq p0 (getPoint "n Enter Center of Circle"))

    (setq p1 (list(- (car p0) (* r 2)) (cadr p0)))

    setq p2 (list(+ (car p0) (* r 2)) (cadr p0)))

    ((Command "circle" p0 r)

    (Command "circle" p1 r)

    (Command "circle" p2 r)

    )

    (四)

    (defun c:tuxing4 ()

    (setq r (getdist "n r=:"))

    (setq p0 (getPoint "n Enter Center of Circle"))

    (setq a1 (list(+ (car p0) (* (cos (/ pi 4)) r)) (+ (cadr p0) (* (cos (/ pi 4)) r))))

    (setq a2 (list(- (car p0) (* (cos (/ pi 4)) r)) (cadr a1)))

    (setq a3 (list(car a2) (- (cadr p0) (* (cos (/ pi 4)) r))))

    (setq a4 (list(car a1) (cadr a3)))

    (Command "line" a1 a2 a3 a4 a1"")

    (Command "circle" p0 r)

    可以了,你试试吧!