Xrefs renamed...

Discussion in 'AutoCAD' started by akdrafter, Jan 7, 2004.

  1. akdrafter

    akdrafter Guest

    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
     
    akdrafter, Jan 7, 2004
    #1
  2. akdrafter

    Jeff Mishler Guest

    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)
    )
    )
    there an easy way of renaming the xref back to the original xref (file)
    name?
     
    Jeff Mishler, Jan 7, 2004
    #2
  3. 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
     
    James Maeding, Jan 7, 2004
    #3
  4. akdrafter

    akdrafter Guest

    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
     
    akdrafter, Jan 7, 2004
    #4
  5. akdrafter

    Jeff Mishler Guest

    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

    and renamed them manually to the original file name but that did not
    work.
     
    Jeff Mishler, Jan 7, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.