- (defun check-text (ent / str)
- (setq matchs '("*M*" "*C*"))
- (setq notmatchs '("*MM*" "*CC*"))
- (if (setq str (entity:getdxf ent 1))
- (and
- (apply 'or (mapcar '(lambda(x)(wcmatch (strcase str) x)) matchs))
- (apply 'and (mapcar '(lambda(x)(wcmatch (strcase str) (strcat "~" x))) notmatchs)))))
-
- (defun findtext ()
- (setq txts (pickset:to-list (ssget '((0 . "*text,attrib,insert")))))
- (setq txts
- (vl-remove-if-not
- '(lambda(txt)
- (cond
- ((/= "INSERT" (entity:getdxf txt 0))
- (check-text txt))
- ((= "INSERT" (entity:getdxf txt 0))
- (setq entlst (block:ent-list (entity:getdxf txt 2)))
- (setq flag nil)
- (while (and (setq ent (car entlst))
- (null flag))
- (if (wcmatch (entity:getdxf ent 0) "*TEXT")
- (setq flag
- (check-text ent)))
- (setq entlst (cdr entlst))
- )
- flag)))
- txts)))
- (defun mark-order (ents)
- (setq i 0)
- (foreach
- ent ents
- (cond
- ((/= "INSERT" (entity:getdxf ent 0))
- ;; 取文字中点
- (setq pt-mid (apply 'point:mid (entity:getbox ent 0)))
- ;; 高度,角度
- (setq h (entity:getdxf ent 40))
- (setq ang (entity:getdxf ent 50))
- (entity:putdxf
- (entity:make-text
- (strcat (itoa (setq i (1+ i)))"#")
- (polar pt-mid (+ (* 0.5 pi) ang) h)
- (* 0.9 h)
- ang 0.8 0 "MM")
- 62
- 1
- ))
- ;; 块引用
- ((= "INSERT" (entity:getdxf ent 0))
- (setq pt-ins (entity:getdxf ent 10))
- (setq ang-ins (entity:getdxf ent 50))
- (setq scale-ins (entity:getdxf ent 41))
- (setq subents (block:ent-list(setq blkname (entity:getdxf ent 2))))
- (setq pt-base (entity:getdxf (tblobjname "block" blkname) 10))
- (setq subents
- (vl-remove-if-not
- '(lambda(x)
- (and (wcmatch (entity:getdxf x 0) "*TEXT")
- (check-text x)))
- subents)
- )
- (foreach
- subent subents
- ;; 取文字中点 坐标变换
- ;;(print (entity:getbox subent 0))
- (setq pt-mid(apply 'point:mid (entity:getbox subent 0)))
- (setq pt-mid (block:bcs2wcs pt-mid pt-base pt-ins ang-ins scale-ins))
- ;; 高度,角度
- (setq h (entity:getdxf subent 40))
- (setq ang (+ (entity:getdxf subent 50)
- ang-ins
- ))
- (entity:putdxf
- (entity:make-text
- (strcat (itoa (setq i (1+ i)))"#")
- (polar pt-mid (+ (* 0.5 pi) ang) h)
- (* 0.9 h)
- ang 0.8 0 "MM")
- 62
- 1
- )))
-
- )))
|