- 积分
- 975
- 明经币
- 个
- 注册时间
- 2011-8-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
用dwgdirect写的,代码如下
using (Services services = new Services())
{
Database db=new Database(false,false);
db.ReadDwgFile(path+"5T-267.dwg",FileShare.Read,false,null);
BlockTable bt;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = new BlockTableRecord();
foreach (ObjectId bto in bt)
{
btr = (BlockTableRecord) tr.GetObject(bto,OpenMode.ForRead);
if (btr.Name == "CAD_BOM")
{
foreach (ObjectId id in btr)
{
DBObject obj = (DBObject)tr.GetObject(id, OpenMode.ForRead);
AttributeDefinition ad = obj as AttributeDefinition;
if (ad != null)
{
MessageBox.Show(ad.Tag.ToString());
MessageBox.Show(ad.TextString.ToString());//,为什么显示为空?还有如果我这个bom中有多行如何把每个tag的多行值都显示出来?请哪位给予指点
}
}
}
}
tr.Commit();
}
}
|
|