Why is this drawing not open?

Discussion in 'AutoCAD' started by Dave F., Apr 28, 2004.

  1. Dave F.

    Dave F. Guest

    Hi All

    A2k2

    This routine reloads all the loaded xrefs in the drawing.
    The chevroned line (should) test to see if the xref drawing is open, & if it
    is save it to ensure it's the latest info.
    The test drawing has multiple xrefs (all overlayed & have the same path),
    but on one it gives the following error description/number:

    Method 'Item' of object 'IAcadDocuments' failed
    -2147467259

    Any ideas what this means?

    TIA
    Dave F.

    ' blue icon
    Sub fxXrefRefresh()
    Dim BlkObj As AcadBlock
    Dim objBlock As AcadDatabase
    Dim Dwg As AcadDocument

    For Each BlkObj In ThisDrawing.Blocks ' cycles through all the blocks
    in the dwg
    If BlkObj.IsXRef Then ' if it's an Xref?
    Debug.Print BlkObj.Name
    On Error Resume Next
    Set objBlock = ThisDrawing.Blocks(BlkObj.Name).XRefDatabase '
    tests to see if it's loaded
    If Err = 0 Then
    ' if it's loaded
    On Error Resume Next".dwg") ' is it open?
    If Err = 0 Then
    ' if it's open
    If Dwg.Saved = False Then
    ' check to see if it's saved
    Dwg.Save
    ' if not save it
    End If ' saved
    End If ' open
    BlkObj.Reload
    ' reload the xref
    End If ' loaded
    End If ' xref
    Next ' block
    End Sub
     
    Dave F., Apr 28, 2004
    #1
  2. Dave F.

    Dave F. Guest

    Oh, & also, is ThisDrawing necessary?
    It seems to work without it.
     
    Dave F., Apr 28, 2004
    #2
  3. Dave F.

    Perion Guest

    Apparently the BlkObj.Name & ".dwg" concatenation is producing a string which
    isn't a valid index in the Documents collection. One thing to keep in mind - a
    string passed to the Item method of the Documents collection is case sensitive.
    Could that be part of the problem? Set a breakpoint and see what string
    BlkObj.Name & ".dwg" is producing. Maybe for the item its failing on the dwg
    extension is capitalized for some reason.

    Perion
     
    Perion, Apr 28, 2004
    #3
  4. Dave F.

    Perion Guest

    A string argument for the Item method is only case-sensitive for the
    SelectionSets collection. My bad :-(
    To debug, I'd just write a little loop (before the fail line) that iterates the
    collection and debug.print each item that's actually in it and compare that with
    the concatenated string being formed when it fails.

    Perion
     
    Perion, Apr 28, 2004
    #4
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.