xstlf您好!在元旦您还上网问问题呀?下面是两个小程序:- ;选封闭图形内一点计算
- (defun c:area2 ()
- (setvar "cmdecho" 0)
- (command "_.undo" "be")
- (setq pt (getpoint "\n请点取要标注的范围内一点:"))
- (command "-boundary" pt "")
- (command "area" "o" (entlast))
- (command "erase" (entlast) "")
- (setq area (getvar "area"))
- (command "text" "j" "c" pt "5" "0" (rtos area 2 3))
- (princ "\n该范围的面积为A=")
- (princ (rtos (/ area 1000000) 2 4))
- (princ "M(")
- (princ (rtos area 2 3))
- (princ "mm)。")
- (command "_.undo" "e")
- (setvar "cmdecho" 1)
- (princ)
- )
- ;选择封闭曲线计算
- (defun c:area3 ()
- (setvar "cmdecho" 0)
- (command "_.undo" "be")
- (princ "\n请选择封闭曲线 :")
- (setq ss (ssget '((0 . "LWPOLYLINE,CIRCLE"))))
- (setq sl (sslength ss) i 0)
- (repeat sl
- (setq ent (ssname ss i) i (1+ i))
- (command "area" "o" ent)
- (setq area (getvar "area"))
- (princ "\n该范围的面积为A=")
- (princ (rtos (/ area 1000000) 2 4))
- (princ "M(")
- (princ (rtos area 2 3))
- (princ "mm)。")
- )
- (command "_.undo" "e")
- (setvar "cmdecho" 1)
- (princ)
- )
|