我试过了,但不起作用。。。。。
- ;GetArea.lsp - Total the areas of selected polyline entities.
- (defun C:GetArea2 (ht scl)
- ;turn off the system echo
- (setvar "cmdecho" 0)
- ;set up a variable to hold the accumulated areas
- (setq myArea 0)
- ;while the user keeps making a selection
- (while(setq ent(entsel))
- ;if an entity was selected and not a point in space
- (if(car ent)
- (progn
- ;let AutoCAD get the area of the object...cheap yet effective way out...
- ;Note: AutoCAD stores the area in the system variable "Area"
- (command "area" "Object" (car ent))
- ;print the area to the command line
- (princ (strcat "\n Ε = " (rtos (getvar "Area") 2 2)" sq.m"))
- ;accumulate the area if it exist
- (if (getvar "Area")(setq myArea(+ myArea (getvar "Area"))))
- )
- )
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq scl(/ (getreal "\n give scale (100,200,500,etc) : ") 100))
- (setq ht(* 0.175 scl))
- ;ask for a text insertion point
- (setq pt1(getpoint "\n insert point: "))
- ;print the area in the drawing
- (command "text" pt1 "" "" (strcat "E = "(rtos myArea 2 2)"sq.m"))
-
- ;suppress the last echo
- (princ)
- )
|