在lisp中使用“命令行隐藏”有时是不可靠的。你可以试试这个:
- (defun C:GetArea2 (/ ent myArea pt1 h )
- ;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 h (getdist "\n give text size:"))
- ;ask for a text insertion point
- (setq pt1(getpoint "\n insert point: "))
- ;print the area in the drawing
- (command "text" pt1 h 0 (strcat "E = "(rtos myArea 2 2)"sq.m"))
-
- ;suppress the last echo
- (princ)
- )
但我不确定这会有多大不同。我唯一的另一个想法是,也许你在UCS而不是世界? |