/// <summary>
/// 取得图层下的所有对象ObjctId
/// </summary>
/// <param name="name">图层名称</param>
/// <returns>ObjctId集合</returns>
public static ObjectIdCollection GetObjectIdsAtLayer(string name)
{
ObjectIdCollection ids = new ObjectIdCollection();
PromptSelectionResult ProSset = null;
TypedValue[] filList = new TypedValue[1] { new TypedValue((int)DxfCode.LayerName, name) };
SelectionFilter sfilter = new SelectionFilter(filList);
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
ProSset = ed.SelectAll(sfilter);
if (ProSset.Status == PromptStatus.OK)
{
SelectionSet sst = ProSset.Value;
ObjectId[] oids = sst.GetObjectIds();
for (int i = 0; i < oids.Length; i++)
{
ids.Add(oids[i]);
}
}
return ids;
}
CAD 取某个图层所有对象的ObjectId
于 2020-04-01 09:08:18 首次发布