本帖最后由 自贡黄明儒 于 2024-8-13 15:14 编辑
重定义块,文字基点不要搞那么远,直接
(vla-getboundingbox (vlax-ename->vla-object name) 'minpoint 'maxpoint)
- (defun t1t1t1 (e / A B EB EN L NAME OBJ)
- (setq en (entget e))
- (setq name (cdr (assoc 2 en)))
- (setq eb (TBLOBJNAME "Block" name))
- (while (setq eb (entnext eb))
- ;;如果不是*TEXT,ATTDEF ,求包围盒
- (setq name (cdr (assoc 0 (entget eb))))
- (if (not (wcmatch name "*TEXT,ATTDEF"))
- (progn
- (setq obj (vlax-ename->vla-object eb))
- (vla-GetBoundingBox obj 'a 'b)
- (setq a (safearray-value a))
- (setq b (safearray-value b))
- (setq L (cons a L))
- (setq L (cons b L))
- )
- )
- )
- ;;如果L存在,求包围盒
- (if L
- (list
- (apply 'mapcar (cons 'min L))
- (apply 'mapcar (cons 'max L))
- )
- )
- )
- ;;选择块
- (defun C:t1 (/ A B E L OBJ)
- (setq e (car (entsel)))
- ;;此块的外围盒
- (setq obj (vlax-ename->vla-object e))
- (vla-GetBoundingBox obj 'a 'b)
- (setq a (safearray-value a))
- (setq b (safearray-value b))
- (setq L (cons a L))
- (setq L (cons b L))
- (princ (list
- (apply 'mapcar (cons 'min L))
- (apply 'mapcar (cons 'max L))
- )
- )
- ;;块最小包围盒
- (princ (t1t1t1 e))
- (princ)
- )
|