分享一个自己初学写的一个简单程序
(DEFUN C:TT()(SETVAR "CMDECHO" 0)
(SETVAR "OSMODE" 0)
(SETQ P1 (GETPOINT "\N 指定基点:"))
(terpri)
(SETQ X (GETREAL "\N 输入长度:"))
(SETQ Y (GETREAL "\N 输入宽度:"))
(IF
(> X Y)
(PROGN
(SETQ D1 (- X Y))
(SETQD2 Y)
(SETQ P2 (POLAR P1 0 D1))
(SETQ P3 (POLAR P2 (* 0.5 PI) D2))
(SETQ P4 (POLAR P3 PI D1))
(SETQ P1 (POLAR P4 (* 1.5 PI) D2))
(COMMAND "PLINE" P1 P2 "A" P3 "L" P4 "A" P1 "")
)
(PROGN
(SETQ D1 (- Y X))
(SETQ D2 X)
(SETQ P2 (POLAR P1 (* 1.5 PI) D1))
(SETQ P3 (POLAR P2 0 D2))
(SETQ P4 (POLAR P3 (* 0.5 PI) D1))
(SETQ P1 (POLAR P4 PI D2))
(COMMAND "PLINE" P1 P2 "A" P3 "L" P4 "A" P1 "")
)
)
(SETVAR "OSMODE" 16383)
(PRINC)
) 多谢分享,建议添加动图gif 画腰形孔的 感谢分享,好有用 (DEFUN C:TT(/ d1 d2 p1 p2 p3 p4 x y)
(SETQ P1 (GETPOINT "\N 指定基点:"))
(SETVAR "CMDECHO" 0)
(SETVAR "OSMODE" 0)
(terpri)
(SETQ X (GETREAL "\N 输入长度:"))
(SETQ Y (GETREAL "\N 输入宽度:"))
(cond
((= X Y)
(progn(alert "\n输入有误,请重新输入")
(vl-exit-with-value 0))
)
((> X Y) (PROGN
(SETQ D1 (- X Y))
(SETQD2 Y)
(SETQ P2 (POLAR P1 0 D1))
(SETQ P3 (POLAR P2 (* 0.5 PI) D2))
(SETQ P4 (POLAR P3 PI D1))
(SETQ P1 (POLAR P4 (* 1.5 PI) D2))
(COMMAND "PLINE" P1 P2 "A" P3 "L" P4 "A" P1 "")
))
((< X Y) (PROGN
(SETQ D1 (- Y X))
(SETQ D2 X)
(SETQ P2 (POLAR P1 (* 1.5 PI) D1))
(SETQ P3 (POLAR P2 0 D2))
(SETQ P4 (POLAR P3 (* 0.5 PI) D1))
(SETQ P1 (POLAR P4 PI D2))
(COMMAND "PLINE" P1 P2 "A" P3 "L" P4 "A" P1 "")
))
)
(SETVAR "OSMODE" 16383)
(PRINC)
)
页:
[1]