Accessing Xref Filenames

Discussion in 'AutoCAD' started by Edward Bagby, Apr 1, 2005.

  1. Edward Bagby

    Edward Bagby Guest

    I want to get the actual filename of the attached xref in a drawing, not the
    xref "name"

    In my case the actual filename and xref name is different. How can I get
    this info?

    The structure of my code is basically:

    Dim xref As AcadBlock
    Dim strXRefFileName As String

    For Each xref In ThisDrawing.Blocks

    If xref.IsXRef Then

    strXRefFileName = [Need to get xref filename here]

    End If

    Next


    Thank you for the help.

    Edward
     
    Edward Bagby, Apr 1, 2005
    #1
  2. Edward Bagby

    Jeff Mishler Guest

    The path is stored with the actual insert of the block. Expanding on your
    code:

    Dim blk As AcadBlock
    Dim xref As AcadExternalReference
    Dim ss As AcadSelectionSet
    Dim iCode(1) As Integer
    Dim vVal(1) As Variant
    Dim strXRefFileName As String

    Set ss = ThisDrawing.PickfirstSelectionSet
    iCode(0) = 0: iCode(1) = 2
    vVal(0) = "INSERT"
    For Each blk In ThisDrawing.Blocks

    If blk.IsXRef Then
    vVal(1) = blk.Name
    ss.Select acSelectionSetAll, , , iCode, vVal
    If ss.Count > 0 Then
    Set xref = ss.Item(0)
    strXRefFileName = xref.Path
    End If
    ss.Clear
    Set xref = Nothing
    End If

    Next
     
    Jeff Mishler, Apr 1, 2005
    #2
  3. Edward Bagby

    Edward Bagby Guest

    Worked like a charm!

    This solution seems so inobvious. How did you ever figure that out. It was
    not in any documentation that I saw.

    Thanks,

    Edward


     
    Edward Bagby, Apr 1, 2005
    #3
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.