比加尔,是你激励我写这篇文章的:
- ; Total area of hatches with certain pattern
- (defun C:test ( / SH enx SS i Lst )
- (setvar 'errno 0)
- (while (/= 52 (getvar 'errno))
- (setq SH (car (entsel "\nSelect source hatch pattern to filter by <exit>: ")))
- (cond
- ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0))
- ((and SH (/= "HATCH" (cdr (assoc 0 (setq enx (entget SH))))) (princ "\nThis is not a "HATCH".")))
- (
- (and
- SH
- (princ (strcat "\nSelect hatches with "" (cdr (assoc 2 enx)) "" pattern to sum their area: "))
- (setq SS (ssget (list (assoc 0 enx) (assoc 2 enx))))
- (repeat (setq i (sslength SS))
- (setq Lst (cons (vla-get-Area (vlax-ename->vla-object (ssname SS (setq i (1- i))))) Lst))
- )
- (not (alert (strcat "\nTotal area of the hatch with "" (cdr (assoc 2 enx)) "" pattern is: " (rtos (apply '+ Lst) 2 2) " units.")))
- )
- (setvar 'errno 52)
- )
- )
- )
- (princ)
- )
|