Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

When using AttachXref api, received following message AutoCAD message - Warning: an error ocurred during Save

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
320 Views, 2 Replies

When using AttachXref api, received following message AutoCAD message - Warning: an error ocurred during Save

As mentioned in the title, when I try to attach an X-ref layer to my Drawing file, received the following error:Screenshot 2021-06-04 200616.png

 

But, I am able to save the drawing successfully. Is there any way how to adress the above error. Following is my code snippet for attaching Xref:

using (Transaction tr = destDb.TransactionManager.StartTransaction())
                {
                    ObjectId XrefID = destDb.AttachXref(filepath1, filepath);
                    BlockReference bref = new BlockReference(Point3d.Origin, XrefID);
                    BlockTable table = tr.GetObject(destDb.BlockTableId, OpenMode.ForWrite) as BlockTable;
                    BlockTableRecord ms1 = tr.GetObject(table[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                    ms1.AppendEntity(bref);
                    tr.AddNewlyCreatedDBObject(bref, true);
                    LayerTable acLyrTbl;
                    acLyrTbl = tr.GetObject(destDb.LayerTableId, OpenMode.ForRead) as LayerTable;
                    if (acLyrTbl.Has("G-XREF"))
                        bref.Layer = "G-XREF";
                    tr.Commit();
                }

 

Thanks,

Ranjan

Labels (1)
2 REPLIES 2
Message 2 of 3
pendean
in reply to: Anonymous

Why don't you just use RECOVER command (and more if needed) to fix the file as the pop-up suggests?
Message 3 of 3
Anonymous
in reply to: pendean

Here, I would like to see an api based solution as I am reading Autodesk Database using autocad apis. I believe the recover solution is through the editor which I cant use as I am not working on an active document.
I have been able to debug the source problem. This occurs when I am trying to attach Xref as mentioned above. And the xref itself has been using layers from a .las file which was imported previously. When I do not use this method of importing layers in xref model the above program works fine.
But, currently the issue is solved from my end without any programming by modifying my CAD dwg at the source by including the required layers instead of using a .las file through the backend program.

 

Anyways, would love to hear if any solutions are there through api programming.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report