- (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)
- (foreach attrib
- (VLAX-SAFEARRAY->LIST
- (VLAX-VARIANT-VALUE (vla-getattributes blockref))
- )
- (cond ((= (vla-get-tagstring attrib) "客户图号")
- (vla-put-textstring attrib drawing-number)
- )
- ((= (vla-get-tagstring attrib) "零件名称")
- (vla-put-textstring attrib part-name)
- )
- ((= (vla-get-tagstring attrib) "设计日期")
- (vla-put-textstring attrib (rtos (getvar "CDATE") 2 0))
- )
- (IF
- (= (vla-get-tagstring attrib) "编号")
- (setq product-code (vla-get-textstring attrib))
- )
- (IF
- (= (vla-get-tagstring attrib) "客户")
- (let ((extracted-code (substr product-code 2 3)))
- (vla-put-textstring attrib extracted-code)
- )
- )
- )
- )
- )
- )
- )
- )
- )
- (princ)
|