
- (defun c:test ()
- (setq e1 nil)
- (setq filename (vl-filename-base (getvar "dwgname")))
- (if (setq space-pos (vl-string-search " " filename))
- (progn
- (setq drawing-number (substr filename 1 space-pos))
- (setq part-name (substr filename (+ space-pos 2)))
- (setq ss (ssget "x" '((0 . "INSERT"))))
- (repeat (setq n (sslength ss))
- (setq blockref (SSNAME SS (setq n (1- n))))
- (setq blockref (vlax-ename->vla-object blockref))
- (if (= (vla-get-HasAttributes blockref) :vlax-true)
- (progn
- (foreach attrib
- (VLAX-SAFEARRAY->LIST
- (VLAX-VARIANT-VALUE (vla-getattributes blockref))
- )
- (if (= (vla-get-tagstring attrib) "产品编码")
- (setq e1 (vla-get-textstring attrib))
- )
- )
- (setq E2 (substr E1 2 3))
- (foreach attrib
- (VLAX-SAFEARRAY->LIST
- (VLAX-VARIANT-VALUE (vla-getattributes blockref))
- )
- (setq attribname (vla-get-tagstring attrib))
- (cond ((wcmatch attribname "客户图号")
- (vla-put-textstring attrib drawing-number)
- )
- ((wcmatch attribname "零件名称")
- (vla-put-textstring attrib part-name)
- )
- ((and
- (wcmatch attribname "设计日期")
- (= (vla-get-textstring attrib) "")
- )
- (vla-put-textstring
- attrib
- (menucmd "m=$(edtime,$(getvar,DATE),yyyy-mo-dd)")
- )
- )
- ((wcmatch attribname "客户")
- (vla-put-textstring attrib E2)
- )
- )
- )
- )
- )
- )
- )
- )
- (princ)
- )
|