Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

renaming of xref with visual lisp

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
0
0
US
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)
)
 
Maybe this is a better approach. although i keep getting a syntax error.

Code:
(defun c:xrefrename (/ ActDoc bnName)

	(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
	(vlax-for bn (vla-get-blocks actdoc)
		(setq bnName (vla-get-Name bn))
		(if
			(and
				(vl-string-search "a1" bnName)
			)
		)

	(princ)
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top