Results 1 to 4 of 4

Thread: An exception pops up when reloading xref block and the dwg file is opened via ReadDwgFile method

  1. #1
    Member
    Join Date
    2009-01
    Posts
    2
    Login to Give a bone
    0

    Angry An exception pops up when reloading xref block and the dwg file is opened via ReadDwgFile method

    I have written the following code snipt to reload one dwg xref, an exception is thrown when reloading. I don't know any better way to implement this function, I appreciate very much if you could provide me any suggestion, comment or idea. Thanks a lot

    Code:
                AcadDatabase acadDB = null;
                Database db = new Database();
                XrefGraph Xref = null;
                XrefGraphNode XrefNode = null;
                Transaction trans = null;
                BlockTable Btable = null;
                BlockTableRecord BTrecord = null;
                try
                {
                    db.ReadDwgFile(@"C:\MEP\All.dwg", FileShare.ReadWrite, false, "");
                    Xref = db.GetHostDwgXrefGraph(true);
                    acadDB = db.AcadDatabase as AcadDatabase;
                    for (int k = 1; k < Xref.NumNodes; k++)
                    {
                        trans = db.TransactionManager.StartTransaction();
                        XrefNode = Xref.GetXrefNode(k);
                        try
                        {
                            acadDB.Blocks.Item(XrefNode.Name).Reload();
                        }
                        catch (System.Exception e)
                        {
                             // an exception is thrown here, it said that:" Catastrophic failure(Exception is form HRESULT:0x8000FFFF (E_UNEXPECTED))     
                        }
    
                        trans.Commit();
                        trans.Dispose();
                    }
                    db.Save();
                }
                finally
                {
                    db.CloseInput(true);
                }
    Last edited by Ed Jobe; 2009-01-06 at 04:25 PM. Reason: Added Code tags.

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: An exception pops up when reloading xref block and the dwg file is opened via ReadDwgFile method

    For one thing, you can't use the Save method on the database. You have to use the SaveAs method.

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,421
    Login to Give a bone
    0

    Default Re: An exception pops up when reloading xref block and the dwg file is opened via ReadDwgFile method

    You may want to use IsXref before trying to reload it. The object might just be a block or an unresolved xref.
    C:> ED WORKING....


    LinkedIn

  4. #4
    Member
    Join Date
    2009-01
    Posts
    2
    Login to Give a bone
    0

    Angry Re: An exception pops up when reloading xref block and the dwg file is opened via ReadDwgFile method

    I have modified the code,
    try
    {
    AcadBlock bl = acadDB.Blocks.Item(XrefNode.Name);
    if (bl.IsXRef)
    {
    bl.Reload();
    }
    }
    catch (System.Exception e)
    {
    // the exception is thrown again.
    // it said that:" Catastrophic failure(Exception is form HRESULT:0x8000FFFF (E_UNEXPECTED))
    }

Similar Threads

  1. 2012: Xref - This file cannot be opened.
    By dva3 in forum ACA General
    Replies: 2
    Last Post: 2012-03-27, 02:28 PM
  2. Highlight Last Opened Block in Block Editor Block List
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2008-10-11, 09:03 PM
  3. creating block - error message pops up
    By gisdude in forum AutoCAD General
    Replies: 2
    Last Post: 2008-04-15, 01:45 PM
  4. Replies: 2
    Last Post: 2007-06-12, 12:20 PM
  5. Random Xref notification balloon pops up
    By mcoffman in forum AutoCAD General
    Replies: 3
    Last Post: 2006-02-09, 03:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •