你好
试试这个
- (defun rplce_Issue_blks(block tablist rev_date / bl block doc file sel
- laylist laystr
- ss subenlst)
- (vl-load-com)
- (setq doc (vla-get-activedocument (vlax-get-acad-object))
- )
- (vla-startundomark doc)
- (or (tblsearch "block" block)
- (not (setq file (findfile (strcat "R:\\AutoCAD\\Blocks\" block ".dwg"))))
- (vla-delete (vla-insertblock (if (eq (getvar "cvport") 1)
- (vla-get-paperspace doc)
- (vla-get-modelspace doc)
- )
- (vlax-3d-point '(0.0 0.0 0.0))
- file
- 1
- 1
- 1
- 0
- )
- )
- )
- ; Added layouts
- (setq laystr (car tablist))
- (foreach lay (cdr tablist)
- (setq laystr (strcat laystr (chr 44) lay))
- )
- ;(princ laystr)
- (and (tblsearch "block" block)
- (ssget "_x" (list (cons 0 "insert") (cons 2 "IFA,IAC,IFC") (cons 410 laystr) (cons 67 1))) ; dxf 67=1 only paperspace
- (progn
- (vlax-for bl (setq sel (vla-get-activeselectionset doc))
- (vla-put-name bl block)
- [color=Red][b] (and (setq att (vlax-invoke bl 'getattributes))
- (vla-put-textstring (car att) rev_date)
- )
- [/b][/color] )
- (vla-delete sel)
- )
- )
- ; This is deffinately Bad Practice (using autolisp in a vlisp routine), but I don't know how to change an attribute any other way...
- ; (If (setq ss (ssget "_x" (list (cons 0 "insert") (cons 2 "IFA,IAC,IFC") (cons 410 laystr) (cons 67 1))))
- ;(Progn
- ; (foreach en (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
- ; (If (= (cdr (assoc 0 (setq subenlst (entget (entnext en))))) "ATTRIB")
- ; (entmod (subst (cons 1 rev_date) (assoc 1 subenlst) subenlst))
- ; (Princ "Couldn't change the date in the new Issue Blocks\n"))
- ; ))(Princ "No Blocks found\n"))
- ; End of Bad Practice
-
- (vla-endundomark doc)
- (princ)
- )
未测试
@+ |