Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Last active July 5, 2020 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/b48e7ba41a88f3e6032abfcbb7f8b6dc to your computer and use it in GitHub Desktop.
Save chuongmep/b48e7ba41a88f3e6032abfcbb7f8b6dc to your computer and use it in GitHub Desktop.
[CommandMethod("SelectionFilter")]
public static void LayerSelection()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
TypedValue[] filterlist = new TypedValue[2];
//select circle and line
filterlist[0] = new TypedValue(0, "CIRCLE,LINE");
//8 = DxfCode.LayerName
filterlist[1] = new TypedValue(8, "0,Layer1,Layer2");
SelectionFilter filter =
new SelectionFilter(filterlist);
PromptSelectionResult selRes = ed.SelectAll(filter);
if (selRes.Status != PromptStatus.OK)
{
ed.WriteMessage(
"\nerror in getting the selectAll");
return;
}
ObjectId[] ids = selRes.Value.GetObjectIds();
ed.WriteMessage("No entity found: "
+ ids.Length.ToString() + "\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment