为什么得不到块的属性值
用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();
}
}
显示的是属性块,BlockTableRecord中不一定有AttributeDefinition,Attrib的Ower是BlockReference,你应该遍历ModelSpace中有Attrib的BlockReference 能提供下大致代码么,我还是没太明白 ivde 发表于 2015-10-27 10:36 static/image/common/back.gif
显示的是属性块,BlockTableRecord中不一定有AttributeDefinition,Attrib的Ower是BlockReference,你应该遍 ...
能给点示例代码么 还是不太懂 BlockTableRecord btr = new BlockTableRecord
这个里面始终为空吧 ivde 发表于 2015-10-27 12:41 static/image/common/back.gif
BlockTableRecord btr = new BlockTableRecord
这个里面始终为空吧
不是是MessageBox.Show(ad.TextString.ToString());这句的输出为空
楼主解决了吗
页:
[1]