本帖最后由 muwind 于 2020-8-7 22:12 编辑
;终于会发网页代码了.....
;这一个副产物:批量获取块中的文字,
;本来的目的是获取仅含文字的块如果文字是,
;有特定特征的文字 对块(主要是匿名块)进行删除或者别的操作,
;但是好像比我想的复杂那么点点
- (defun c:getbt(/ blks ss m n e nam bnnew namlst)
- (setq BLKs (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))));取得图形的Blocks集合
- (if (setq ss (ssget '((0 . "INSERT"))))
- (progn
- (setq namlst '())
- (repeat (setq n (sslength ss))
- (if (setq e (ssname ss (setq n (1- n))))
- (progn
- (setq nam (vla-get-name (vlax-ename->vla-object e)));获取块名字
- (if (= (member nam namlst) nil)
- (setq namlst(cons nam namlst))
- )
- )
- )
- )
- (foreach n namlst
- (progn
- (setq strlst '())
- (vlax-for m (vla-item blks n)
- (if (= (vla-get-objectname m) "AcDbText")
- (setq strlst (cons (vla-get-TextString m) strlst))
- )
- )
- (if strlst
- (progn
- (princ (strcat "\n My name is " n ";All texts in my body are:"))
- (princ strlst)
- )
- )
- )
- )
- )
- )
- (princ)
- )
|