Message 1 of 9
ReadDwgFile doc.Database.Insert:eSelfReference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a bloks.dwg, there are many block definition in the blocks.dwg. one of them called "ABC"。
I want import "ABC" in my current dwg.
The following code doesn't work: eSelfReference !!!why ???
Document doc = CADAPP.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
try
{
using (Database dbSource = new Database(false, true))
{
dbdbSource .ReadDwgFile(@"d:\blocks.dwg", System.IO.FileShare.Read, true, null);
dbdbSource .CloseInput(true);
using (DocumentLock docLock = doc.LockDocument())
{
using (Transaction trans = doc.TransactionManager.StartTransaction())
{
//insert it as a new block
ObjectId id = doc.Database.Insert("ABC", dbdbSource , false);
trans.Commit();
}
}
}
}
catch (Exception eee)
{
MessageBox.Show(eee.Message);
}