public String[] list(FilenameFilter filter) {
String names[] = list()
if ((names == null) || (filter == null)) {
return names
}
ArrayList v = new ArrayList()
for (int i = 0 i <names.length i++) {
if (filter.accept(this, names[i])) {
v.add(names[i])
}
}
return (String[])(v.toArray(new String[0]))
}
filter.accept(this, names[i])这里才是传递参数的地方!
计算中心点1(defun zxd181 (obj / obj ss x y)
(vla-getboundingbox obj 'x 'y)
(setq ss (mapcar 'vlax-safearray->list (list x y)))
(list (mapcar 'car ss) (mapcar 'cadr ss))
)
建立无名块
(defun wmk1815 (ss / ent name pt ss ss1 ss2 ss3 x x1 x2 y1 y2)
(setq ss1 '())
(while (setq ent (ssname ss 0)) (setq ss (ssdel ent ss) ss1 (cons ent ss1)) )
(setq ss2 (mapcar 'zxd181 (mapcar 'vlax-ename->vla-object ss1)))计算坐标
(setq ss3 (vl-sort (apply 'append (mapcar 'car ss2)) '<) x1 (car ss3) x2 (last ss3))最小x1,最大x2
(setq ss3 (vl-sort (apply 'append (mapcar 'cadr ss2)) '<) y1 (car ss3) y2 (last ss3))最小y1,最大y2
(setq pt (mapcar '* '(0.5 0.5) (list (+ x1 x2) (+ y1 y2))))计算中心点完成
(entmake (list '(0 . "block") '(2 . "*U") '(70 . 1) (cons 10 pt)))
(mapcar '(lambda (x) (entmake (cdr (entget x)))) ss1)
(setq name (entmake '((0 . "ENDBLK"))))
(mapcar 'entdel ss1)
(entmake (list '(0 . "INSERT") (cons 2 name) (cons 10 pt)))
)
例
(defun c:tes ( / ss)
(vl-load-com)
(princ "\n请选择要变为块的对象")
(if (setq ss (ssget))
(wmk1815 ss)变为无名块
)
(princ)
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)