本帖最后由 q3_2006 于 2013-12-30 07:14 编辑
275437962 发表于 2013-12-29 21:45 
我看了,你是先选一组,然后再选所有要处理的,可是我执行程序不是这样的提示,没有要求我选全部的,只是 ...  - ;;;第二版,只能处理各组图元数量相同的情况
- (defun c:tt ( / a b bnm box dxf5 el en i l la lst lst_en lst_hand n pt ss ss0 ssx x y)
- (defun lst2ss (lst_en / ss en)
- (setq ss (ssadd))
- (foreach en lst_en
- (if (= (type en) 'ename)
- (ssadd en ss)
- )
- )
- (if (= (sslength ss) 0)
- nil
- ss
- )
- )
- (defun fd ( l n / a b )
- (while l
- (repeat n
- (setq a (cons (car l) a)
- l (cdr l)
- )
- )
- (setq b (cons (reverse a) b)
- a nil
- )
- )
- (reverse b)
- )
- (vl-load-com)
- (vl-cmdf "undo" "be")
- (print "\n选择任意一组处理对象:")
- (setq ss0 (ssget '((0 . "LINE")))
- n (sslength ss0)
- la (Vlax-Get (Vlax-Ename->Vla-Object (ssname ss0 0)) 'Layer )
- )
- (print "\n选择全部处理对象:")
- (setq ss (ssget (list '(0 . "LINE")))
- bnm (getstring "\输入块名:")
- i 0
- lst_hand '()
- )
- (repeat (sslength ss)
- (setq en (ssname ss i)
- dxf5 (cdr (assoc 5 (entget en)))
- )
- (setq lst_hand (cons dxf5 lst_hand))
- (setq i (1+ i))
- )
- (setq lst_hand (vl-sort lst_hand (function (lambda (x y) (< x y)))))
- (setq lst (fd (mapcar 'handent lst_hand) n))
- (mapcar '(lambda(x)
- (setq ssx (lst2ss x)
- box (acet-geom-ss-extents ssx t)
- pt (mapcar '* '(0.5 0.5 0.5) (mapcar '+ (car box) (cadr box)))
- )
- (command "erase" ssx "")
- (command "-insert" bnm pt "" "" "")
- (Vlax-Put-Property (Vlax-Ename->Vla-Object (entlast)) 'Layer la)
- (vlax-for X
- (vla-item (vla-get-blocks
- (vla-get-activedocument (vlax-get-acad-object))
- )
- bnm
- )
- (setq el (cons (vlax-vla-object->ename X) el))
- )
- (mapcar '(lambda (x) (VLA-PUT-COLOR (Vlax-Ename->Vla-Object x) 0))el)
- ) lst)
- (vl-cmdf "undo" "e")
- )
|