As mentioned in the title, when I try to attach an X-ref layer to my Drawing file, received the following error:
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
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.