- 积分
- 190
- 明经币
- 个
- 注册时间
- 2011-6-21
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我创建了一个块,这里代码就不写了,然后我想用下面这个方法实现点击块,然后该块的属性名和属性值都出现在windows窗体的文本框中,可是块得属性我获取出来了,但不知道怎么让它显示在文本框中,在代码中应该怎么写啊,请指点
[CommandMethod("sel")]
public static void BrowseBlock()
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
TypedValue[] filterValues = { new TypedValue((int)DxfCode.Start, "INSERT")};
SelectionFilter filter = new SelectionFilter(filterValues);
PromptSelectionOptions opts = new PromptSelectionOptions();
opts.MessageForAdding = "请选择图形中的块对象";
PromptSelectionResult res = ed.GetSelection(opts, filter);
if (res.Status != PromptStatus.OK)
{
return;
}
SelectionSet ss = res.Value;
ObjectId[] ids = ss.GetObjectIds();
Transaction trans = db.TransactionManager.StartTransaction();
foreach (ObjectId blockid in ids)
{
BlockReference blockref = (BlockReference)trans.GetObject(blockid, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(blockref.BlockTableRecord, OpenMode.ForRead);
btr.Name //属性名
btr.Dispose();
AttributeCollection atts = blockref.AttributeCollection;
foreach (ObjectId attid in atts)
{
AttributeReference attref = (AttributeReference)trans.GetObject(attid, OpenMode.ForRead);
attref.TextString //属性值
}
}
}
|
|