|
但是,遍历这个层确实找到了这2个DBPoint对象,本函数却无法得到,不知错在哪里。
public List 得到实体(Document doc, string 实体类型, string 层名)
{
List et = new List();
using (DocumentLock docLock = doc.LockDocument())
{
TypedValue[] filList = new TypedValue[2];
filList[0] = new TypedValue((int)DxfCode.Start, 实体类型);
filList[1] = new TypedValue((int)DxfCode.LayerName, 层名);
SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult res = doc.Editor.SelectAll(filter);//问题出在这里:执行此句后res的结果是"errors,"
if (res.Status == PromptStatus.OK)
{
using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
{
foreach (ObjectId id in res.Value.GetObjectIds())
{
Entity entObject = trans.GetObject(id, OpenMode.ForWrite) as Entity;
et.Add(entObject);
}
trans.Commit();
}
}
}
return et;
}
提示:如果把实体类型参数换成"DBText"则能返回给定层中的所有DBText对象。
为什么实体类型参数为"DBPoint"却不能得到给定层中的DBPoint对象。
|
|