可以这样写
 - (defun Getatts (obj /)
- (mapcar '(lambda (att)
- (list att ;_属性Object
- (vla-get-tagstring att) ;_属性标签
- (vla-get-textstring att) ;_属性值
- )
- )
- (vlax-invoke obj 'GetAttributes) ;_全部属性Object
- );_((属性1 Tag1 textstring1) ....)
- )
- (defun c:tt (/ ss sl ms e el)
- (if (setq ss (ssget '((2 . "GC200") (66 . 1)))) ;_过滤属性酷爱
- (progn
- (setq sl (sslength ss)
- ms (vla-get-modelspace
- (vla-get-activedocument (vlax-get-acad-object))
- )
- )
- (while (setq e (ssname ss (setq sl (1- sl)))) ;_取出实体
- (setq el (cons e el));_构造实体列表
- )
- (mapcar '(lambda (x / inspt atts height txt cir)
- (setq inspt (vla-get-InsertionPoint x) ;_
- atts (getatts x) ;_属性列表
- height (cadr (assoc "height" (mapcar 'cdr atts))) ;_找出height属性,注意大小写
- )
- (setq cir (vla-AddCircle ms inspt 0.5));_绘制圆
- (vla-put-layer cir "0");_修改圆图层
- (setq txt (vla-AddText ms height inspt 2.5));_写高程字
- (vla-put-layer txt "0");_修改字图层
- )
- (mapcar 'vlax-ename->vla-object el);_转换为Object列表
- )
- )
- )
- (princ)
- )
|