I am trying to rename an xref with lisp. I tried to use rename and the command line but you cannot use wildcards at the command line. The file would already be attached with a name of "xxxa1.dwg". what i would like to do is rename the xref "A1", so i can have multiple instances of the same drawing file referenced in the drawing for layer seperation etc. Below is some code I copied from the Autocad discussion group. any ideas on how to make it function how I need? I have commented out the rename line as it does not function.
Code:
(defun c:test (/ blocks blockname)
(setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for block blocks
(if (wcmatch (setq blockname (vla-get-name block)) "*A1")
(print blockname) ;redefine block here
;(command "-rename" "b" blockname "a1")
))
(princ)
)