Xrefs renamed...

akdrafter

Usenet Archive
Joined
Dec 16, 2003
Messages
41
Reaction score
0
Hello Again,

If I have some xrefs that have had their "Reference Name" renamed, is there an easy way of renaming the xref back to the original xref (file) name?

Example:
Original Xref Name (file name) : x###01.dwg
Xref Manager Reference Name: 01

Thus... Xref Reference Name: 01 = x###01.dwg

Desired: x###01 = x###01.dwg

Thanks In Advance.

"Catch" Ya Later,
AKDRAFTER
 
Here's one I wrote last year to address the old R14 method of naming LFN xrefs. It should do what you want.

Jeff

;| Routine to find any xref's in the drawing and if they are in the same directory as the drawing, strip the path down to just the xref'ed drawing name. If the xref insert name does not match the actual drawing name (ala R14 rename to XREF1, XREF2, etc.) change it to match. Written by Jeff Mishler July 3, 2003 Removed (commeted out) path stripping, 7/7/03 |;

(defun C:XR2 (/ *ACAD* *BLOCKS* *DOC* BLK BLKNAME
BLKPATH DWGPATH SS XENT XREFDBASE)
(vl-load-com)
(or *acad* (setq *acad* (vlax-get-acad-object)))
(or *doc* (setq *doc* (vla-get-activedocument *acad*))) (setq *blocks* (vla-get-blocks *doc*)) (setq dwgPath (vla-get-path *doc*))

(vlax-for x *blocks*
(if (= (vla-get-isxref x) :vlax-true)
(progn
(if (setq ss
(ssget "x"
(list (cons 0 "INSERT")
(cons 2 (vla-get-name x)))
)
)
(progn
(setq blk (vlax-ename->vla-object (ssname ss 0)))
(setq xEnt x)
(blk_fix blk)
(if (setq xrefDBase (vla-get-xrefdatabase x))
(vlax-for xx (vla-get-blocks xrefDBase)
(if (= (vla-get-isXref xx) :vlax-true)
(progn
(setq xEnt xx)
(vlax-for xxx (vla-get-modelspace xrefDBase)
(if
(and
(= (vla-get-objectname xxx) "AcDbBlockReference")
(= (vla-get-name xxx)(vla-get-name xEnt))
)
(blk_fix xxx)
)
)
)
)
)
)
)
)
)
)
)
(princ)
)

(defun blk_fix (blk / )
(setq blkname (vla-get-name blk))
(setq blkpath (vla-get-path blk))
;;; (if (wcmatch (strcat (strcase blkpath))
;;; (strcat (strcase dwgpath) "*")
;;; )
;;; (vla-put-path
;;; blk
;;; (while (wcmatch blkpath "*\\*")
;;; (setq blkpath (substr blkpath 2))
;;; )
;;; )
;;; )
(while (wcmatch blkpath "*\\*")
(setq blkpath (substr blkpath 2))
)
(while (wcmatch blkpath "*.*")
(setq blkpath (substr blkpath 1 (1- (strlen blkpath)))) ) (if (not (= blkname blkpath)) (vla-put-name xEnt blkpath) )
)
akdrafter said:
Hello Again,

If I have some xrefs that have had their "Reference Name" renamed, is
there an easy way of renaming the xref back to the original xref (file)
name?
 
I am writing a routine to rename xrefs according to criteria in a dialog box. You have to watch out for two xrefs of the same filename. thats pretty minor though. The request I usually get is a routine to prefix all xrefs with a z or something to make them sort together. Also a tool to put them all on decent layer names.
I'll post it when done.

akdrafter
|>Hello Again,
|>
|>If I have some xrefs that have had their "Reference Name" renamed, is there an easy way of renaming the xref back to the original xref (file) name? |> |>Example:
|>Original Xref Name (file name) : x###01.dwg
|>Xref Manager Reference Name: 01
|>
|>Thus... Xref Reference Name: 01 = x###01.dwg
|>
|>Desired: x###01 = x###01.dwg
|>
|>Thanks In Advance.
|>
|>"Catch" Ya Later,
|>AKDRAFTER

James Maeding
Civil Engineer/Programmer
 
Jeff,

As Always you are awesome. Well, when it works. :-)

Automation Error. Duplicate record name

Any ideas. I did have two nested xrefs and I opened the nested xrefs and renamed them manually to the original file name but that did not work.

"Catch" Ya Later,
AKDRAFTER
 
Hmmm, I've used this a number of times and never seen that..... Could you give me an example of the drawing name, xref names, and actual block names in a typical drawing? I may be able to make sense of it then.

Jeff

akdrafter said:
Jeff,

As Always you are awesome. Well, when it works. :-)

Automation Error. Duplicate record name

Any ideas. I did have two nested xrefs and I opened the nested xrefs
and renamed them manually to the original file name but that did not work.
 

Latest threads

Back
Top