- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
...or can I open it as ReadOnly?
I want to gather some data from another drawing, specifically in my case, some block info and layout tab info. I took some code I had for "Design Center" like importing of blocks for insertion. But in this case, I would like to pull the data regardless if the drawing is in use or not. One work around, I thought of, is to copy the drawing to my temp folder then open it. But, I thought first to see if there is an easier way.
Current code I have so far, I feed the method the drawing name I want to read:
public static void fetchDwgData(Database acDb, Editor acEd, string dsDwg)
{
DocumentCollection acDm = acApp.DocumentManager;
Database dsDb = new Database(false, true);
try
{
dsDb.ReadDwgFile(dsDwg, System.IO.FileShare.Read, true, "");
ObjectIdCollection blkIds = new ObjectIdCollection();
using (Transaction acTrans = acDb.TransactionManager.StartOpenCloseTransaction())
{
BlockTable dsBlkTbl = (BlockTable)acTrans.GetObject(dsDb.BlockTableId, OpenMode.ForRead, false);
foreach (ObjectId btrId in dsBlkTbl)
{
using (BlockTableRecord btr = (BlockTableRecord)acTrans.GetObject(btrId, OpenMode.ForRead, false))
{
if (!btr.IsAnonymous && !btr.IsLayout)
{
//do stuff
}
}
}
}
dsDb.Dispose();
}
catch
{
//exiting due to error
}
}
Solved! Go to Solution.