乞丐版,自己改一下吧,不会改就凑合着用
- (defun c:ttt (/ area en lst n obj obj1 old pt1 pt2 ss)
- (setq old (getvar "osmode"))
- (setvar "osmode" 0)
- (prompt "\n选择外框:")
- (setq ss (ssget '((0 . "lwpolyline") (8 . "1")))) ;_无例图,假设边界图层为1
- (repeat (setq n (sslength ss))
- (setq en (ssname ss (setq n (1- n)))
- obj (vlax-ename->vla-object en)
- area (vla-get-area obj))
- (setq obj1 (car (vlax-safearray->list
- (vlax-variant-value (vla-offset obj 1))))) ;_无例图,假设边界偏移1为宜
- (if (< (vla-get-area obj1) area)
- (progn (vla-delete obj1)
- (setq obj1 (car (vlax-safearray->list
- (vlax-variant-value (vla-offset obj -1))))))) ;_无例图,假设边界偏移1为宜
- (setq lst (vl-remove-if-not '(lambda (x) (= 10 (car x)))
- (entget (vlax-vla-object->ename obj1)))
- lst (mapcar 'cdr (cons (last lst) lst)))
- (vla-getboundingbox obj1 'pt1 'pt2)
- (vla-delete obj1)
- (command "zoom"
- (vlax-safearray->list pt1)
- (vlax-safearray->list pt2))
- (command "trim" en "" "f")
- (foreach n lst (command n))
- (command "" "")
- (command "zoom" "p"))
- (setvar "osmode" old)
- (princ))
|