Is there a way by using VBA to rename an Xref?

Discussion in 'AutoCAD' started by John Knighton, Aug 21, 2003.

  1. Is there a way by using VBA to rename an Xref? For example, I have a file
    referenced into several hundred drawings called "400WAPR30x42.dwg" but I
    want to rename this file to "WAPR30x42.dwg". Any help would be greatly
    appreciated. Thank you.


    John K.
     
    John Knighton, Aug 21, 2003
    #1
  2. John Knighton

    cascadtx Guest

    Not VBA but maybe the AutoCAD 2004 Reference Manager
    tool can do what you want without coding?
     
    cascadtx, Aug 21, 2003
    #2
  3. The code I posted works just fine to change the NAME of an xref. Now, if what
    John actually wants to do is repath and rename the xref, that is a different
    matter, but it can still be done through code.
     
    Chuck Gabriel, Aug 22, 2003
    #3
  4. My mistake. I'm a newbie to VBA programming What I really want to do is to
    specify a new file name for this reference file which I guess would mean
    repathing it. Any help would be greatly appreciated. thank you.
     
    John Knighton, Aug 22, 2003
    #4
  5. This should set you on the path.

    Sub main()
    ThisDrawing.Blocks("400WAPR30x42").Name = "WAPR30x42"
    Dim objSelSet As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets("MySset").Delete
    On Error GoTo 0
    Set objSelSet = ThisDrawing.SelectionSets.Add("MySset")
    Dim intFilterType(0) As Integer
    Dim varFilterData(0) As Variant
    intFilterType(0) = 2
    varFilterData(0) = "WAPR30x42"
    objSelSet.Select acSelectionSetAll, , , intFilterType, varFilterData
    Dim objXref As AcadExternalReference
    For Each objXref In objSelSet
    objXref.Path = "Z:/WAPR30x42.dwg"
    Next
    Set objXref = Nothing
    objSelSet.Delete
    Set objSelSet = Nothing
    ThisDrawing.Blocks("WAPR30x42").Reload
    End Sub
     
    Chuck Gabriel, Aug 22, 2003
    #5
  6. Thanks for all your help and time Chuck. I'll give it a try.
     
    John Knighton, Aug 22, 2003
    #6
  7. John Knighton

    gvanaco Guest



    Can you do the same without opening the xref path.
    I mean, not loading the drawing.
     
    gvanaco, Aug 26, 2003
    #7
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.